^
312/382-5050
Computer Direct
Programmer's
Reference Guide for
the ATARI 400/800
Computers
David Heiserman
Programmer's
Reference Guide
for the
ATARI' 400/800
Computers
David Heiserman
HoujQrd UJ. Sams & Co., Inc.
4300 WEST 62ND ST. INDIANAPOLIS, INDIANA 46268 USA
Copyright © 1984 by David Heiserman
FIRST EDITION
FIRST PRINTING
All rights reserved. No part of this book shall be repro-
duced, stored in a retrieval system, or transmitted by any
means, electronic, mechanical, photocopying, record-
ing, or otherwise, without written permission from the
publisher. No patent liability is assumed with respect to
the use of the information contained herein. While
every precaution has been taken in the preparation of
this book, the publisher assumes no responsibility for
errors or omissions. Neither is any liability assumed for
damages resulting from the use of the information con-
tained herein.
International Standard Book Number: 0-672-22277-9
Library of Congress Catalog Card Number: 83-51616
Edited by Welborn Associates
Illustrated by D.B. demons
ATARI®, AOCP" and 800^" are trademarks of and used by
permission of Atari, Inc.
This book is published by Howard W. Sams & Co., Inc.
which is not affiliated with Atari, Inc. and Atari is not
responsible for any inaccuracies.
Printed in the United States of America.
Programmer's Reference Guide
for the
ATARI® 400 7800™ Computers
David L Heiserman has been a freelance writer
since 1968. He is the author of more than 100
magazine articles and 20 technical and scientific
books. He studied applied mathematics at Ohio
State University and is especially interested in the
history and philosophy of science. He is the
author of the Sams books Intermediate Program-
ming for the TRS-80 and Intermediate-Level
Apple II Handbook.
Preface
The ATARI 400 and 800 Personal Computers are marvel-
ous machines. The graphics system is, I think, incompara-
ble; and it is no coincidence that the graphics in Chapters
4 and 5 occupy more space in this book than any other
single topic. The I/O system is unusually flexible, and
much of the material in this book deals with that part of
the system; particularly Chapter 6.
The ATARI 400/800 Operating System holds its own in
terms of quality and performance. And unlike some other
brands of personal computers, the operating system is
wide open for experimentation. Chapters 8 and 9 are
especially meaningful in this regard, because they map the
entire operating system and review the 6502 instruction
set. These chapters indicate addresses and relevant data in
both hexadecimal and decimal formats (the latter being
more appropriate for use with ATARI BASIC).
This book is organized by general topics so that the
reader can get access to certain information in the most
effective way. That sort of format is especially useful for
someone who is already familiar with the most common
ATARI Home Computer features, and wants to know
more about them. It is also a guide for users who are
accustomed to other personal computers, but want to
become familiar with the special features of the ATARI
system in the shortest possible time (see especially Chap-
ters 1, 2, and 3).
That is not to say that a beginner cannot learn anything
from this book— quite the contrary. The organization of
material in this book is most satisfactory for a beginner
who has a desire to experiment with new ideas and tech-
niques on a first-hand basis. Although such an individual
might not fully understand the finer points of some topics,
the mere effort guarantees a level of success that is often
difficult to achieve from simpler, step-by-step pre-
sentations.
I would like to acknowledge the invaluable assistance
offered by my personal secretary, Robin M. Yates. She
prepared many of the tables and drawings, proofread the
drafts, and assembled the final manuscript for us.
David Heiserman
Contents
CHAPTER 1
Getting Started 13
SOME ATARI SYSTEM CONFIGURATIONS 15
A Minimum Working System 15
Minimum System Plus Program Recorder 16
Minimum System Plus One Disk Drive 17
A Common Multiple-Peripheral System 18
SOME SPECIAL KEYBOARD OPERATIONS 19
Some Control Keys 20
SOME SCREEN EDITING FEATURES 22
WORKING WITH THE PROGRAM RECORDER 23
Connecting the Program Recorder to the System 24
Saving and Loading Programs With the Program Recorder . . 24
ROUTINE DISK OPERATIONS 26
Displaying the Current Disk Directory 26
Returning to BASIC 28
Copying Files to the Same Disk 28
Deleting Files 30
Renaming Existing Files 31
Locking Files 32
Unlocking Files 32
Copying DOS Files 32
Formatting a Disk 33
Duplicating an Entire Disk 33
Getting MEM.SAV Onto a Disk 35
An Alternative File-Copying Operation 35
The Machine-Language Options 36
Saving and Loading Programs With the Disk Drives 36
CHAPTER 2
ATARI BASIC Notation, Rules, and Limitations 39
NUMERIC AND STRING CONSTANTS 39
Numeric Constants 40
String Constants 42
BASIC VARIABLES AND VARIABLE NAMES 44
Numeric Variables 45
String Variables 47
DIMENSIONING STRING VARIABLES AND NUMERIC
ARRAYS 48
DIMensioning String Variables 49
Subscripted Numeric Variables and Arrays 51
OPERATIONS AND OPERATORS 55
Arithmetic Operators 55
Relational Operators 56
Logical Operators 62
Order of Precedence for Operators 64
CHAPTER 3
The BASIC Programming Language 67
A SUMMARY OF STATEMENTS, COMMANDS, AND
FUNCTIONS 68
A SUMMARY OF ATARI BASIC SYNTAX AND APPLICATIONS . . 73
CHAPTER 4
The Text and Graphics Screens 115
FEATURES COMMON TO ALL SCREEN MODES 115
MODE-0 GRAPHICS 143
Organization of the Mode-0 Color Registers 144
Working With the Mode-0 Column/Row Format 145
Working With the Mode-0 Margins 147
Using the POSITION Statement 148
Alternative Column/Row Techniques 148
Using LOCATE, GET, and PUT in Mode 149
The Mode-0 Screen RAM Format 150
MODE-1 AND MODE-2 GRAPHICS 152
Organization of the Mode-1 and Mode-2 Color
Registers I53
Accessing the Character Set From Modes 1 and 2 154
Working With the Mode-1 and -2 Column/Row Format ... 155
Using the POSITION Statement 159
Alternate Column/Row Techniques 160
Using LOCATE, GET, and PUT in Modes 1 and 2 165
The Mode-1 and Mode-2 Screen RAM Formats 166
Full-Screen Formats 168
CUSTOM CHARACTERS SETS FOR MODES 0, 1, AND 2 179
THE FOUR-COLOR MODES: 3, 5, AND 7 182
Working With the Color Registers 183
Column/Row Screen Formats and Graphics Operations ... 184
The Screen RAM Address Formats and Operations 188
TWO-COLOR MODES 4 and 6 199
Wori^ing With the Color Registers for
Screen Modes 4 and 6 199
Column/Row Screen Formats and Operations for
Modes 4 and 6 204
Screen RAM Formats and Operations for Modes 4 and 6 . . 209
THE 2-COLOR MODE-8 SCREEN 216
CHAPTER 5
Player/Missile Graphics 239
PLAYER AND MISSILE CONFIGURATIONS 240
Bit Maps for the Player Figures 241
Bit Maps for the Missile Figures 243
The Overall Player/Missile Bit Map 245
Setting the Starting Address of the Player/Missile
Bit Map 247
Protecting the Player/Missile Bit Map 249
ADJUSTING THE WIDTH OF THE PLAYER/MISSILE FIGURES ... 250
SETTING PLAYER/MISSILE COLORS 251
INITIATING AND TERMINATING PLAYER/MISSILE
GRAPHICS 251
MOVING THE PLAYER/MISSILE FIGURES !!!!!! 254
PLAYER/PLAYFIELD PRIORITIES 255
COLLISION DETECTION 257
CHAPTER 6
More About I/O Operations 263
WORKING WITH THE PROGRAM RECORDER I/O 263
ATASCII-Coded BASIC Program— LIST'C:"
and ENTER"C:" 264
Nonprogram Files— PRINT and INPUT 266
Nonprogram Files— PUT and GET 268
WORKING WITH THE DISK DRIVE I/O 270
ATASCII-Coded BASIC Programs— LIST "D:"
and ENTER "D:" 270
Nonprogram Files— PRINT and INPUT 272
Nonprogram Files— PUT and GET 274
SAVING, LOADING, AND RUNNING
BINARY FILES UNDER DOS 275
Saving Binary Programs and Data 276
Loading and Running Binary Programs 277
OPENING AND CLOSING lOCB CHANNELS 278
USING THE XIO COMMAND 283
Controlling Outgoing Lines With XIO 34 285
Configuring Baud Rate, Word Size, and Stop Bits
with XIO 36 285
Setting Translation Modes and Parity with XIO 38 286
CHAPTER 7
A Miscellany of Principles and Procedures 289
MORE ABOUT THE SOUND FEATURES 289
The SOUND Statement 290
Reproducing Musical Scores 292
Experimenting With Sound Effects 292
MORE ABOUT THE USR FUNCTION 293
Passing Values to a Machine Routine 2%
Passing Values From a Machine Language Routine 300
SCREEN DISPLAY LISTS 300
The ANTIC Instruction Set 300
Structure of a Display List 303
Locating the Display List 306
A LOOK AT TOKENIZED BASIC 307
CHAPTER 8
The ATARI Memory Map 3ii
ZERO-PAGE AND STACK RAM 313
OPERATING SYSTEM AND BASIC RAM 322
Operating System RAM: 512-1151 322
BASIC System RAM: 1152-1535 337
DOS RAM USAGE: 1792-10879 338
BASIC ROM AREA: 40960-49151 338
HARDWARE I/O ROM AREA: 53248-55295 340
The CTIA (or GTIA) Device 341
The POKEY Device 343
The PIA Device 345
THe ANTIC Device 345
OPERATING SYSTEM ROM AREA: 55296-65535 346
CHAPTER 9
The 6502 Instruction Set 349
APPENDIX A
Number-System Base Conversions 38i
HEXADECIMAL-TO-DECIMAL CONVERSIONS 382
DECIMAL-TO-HEXADECIMAL CONVERSIONS 384
CONVENTIONAL DECIMAL TO 2-BYTE DECIMAL FORMAT ... 385
TWO-BYTE DECIMAL TO CONVENTIONAL
DECIMAL FORMAT 387
BINARY-TO-DECIMAL CONVERSION 387
BINARY-TO-HEXADECIMAL CONVERSION 388
HEXADECIMAL-TO-BINARY CONVERSION 390
DECIMAL-TO-BINARY CONVERSION 390
A COMPLETE CONVERSION TABLE FOR DECIMAL 0-255 391
APPENDIX B
ATARI BASIC Reserved Words and Tokens 395
APPENDIX C
ATARI Character Codes 40i
APPENDIX D
ATARI Keyboard Codes 425
APPENDIX E
Screen RAM Addressing Ranges for the
ATARI Screen Modes 435
APPENDIX F
Derived Trigonometric Functions 469
APPENDIX G
ATARI Error and Status Codes 471
APPENDIX H
ATARI 400/800 Hardware Details 479
Index 489
Chapter 1
Getting Started
The ATARI® 400^/800™ personal computer systems are
adaptable to a wide range of configurations and possible
operating schemes. The purpose of this opening chapter is
to introduce some of those features.
Figs. 1-1 and 1-2 show the basic console units for models
400 and 800, respectively. One obvious difference between
them is the nature of the keyboard. The ATARI 400 Home
Computer uses a film, touch-sensitive keyboard, while the
800 model uses an ordinary mechanical-key mechanism.
Fig. 1-1 . The ATARI 400 Home Computer console. (Courtesy Atari,
Inc.)
13
Fig. 1-2. The ATARI 800 Home Computer console. (Courtesy Atari,
Inc.)
There are a couple of less-obvious differences. For one,
the ATARI 800 Home Computer can accept two different
program cartridges, while the 400 can accept only one.
Fig. 1-3 shows the arrangement of jacks and switches
along the right-hand side of the ATARI 800 console unit.
The arrangement for the model 400 is similar, but does not
include the MONITOR jack. That simply means that the
400 must use an ordinary tv receiver as its display screen,
while the 800 offers the option of using a tv receiver or a
monitor.
(
MONITOR
PERIPHERAL
W® ® ® ® (9 gl ^
I® ® ® ® ® ® ®1
2-CHAN-3
JiJ
POWER
ON OFF
m
POWER
IN
Fig. 1-3. Connection panel for the Model 800. The Model 400 is
identical except for the lack of a MONITOR jack.
For the most practical purposes, however, the 400 and
800 models are identical, and they are treated as such
throughout this book.
Also, it will be assumed through this book that the
ATARI BASIC cartridge is installed. As far as the 400 model
is concerned, that means plugging it into the only slot that
14
is available for that purpose— under the hatch just above
the keyboard assembly. For the 800 unit, the BASIC car-
tridge must be installed in the left-hand cartridge slot.
(The discussions further assume that the 800's right-hand
cartridge slot is unused.)
SOME ATARI SYSTEM CONFIGURATIONS
The individual components of an ATARI system must be
connected in certain ways if that overall system is to func-
tion properly. This section outlines several commonly
used systems.
A Minimum Working System
Fig. 1-4 illustrates the minimum working ATARI system: a
console unit and an ordinary tv receiver.
CONVENTIONAL
TV RECEIVER
CONVENTIONAL TV
ANTENNA OR CABLE
o
=
ATARI 400/800
CONSOLE
Fig. 1-4. Diagram of the simplest ATARI Home Computer system.
15
The power-transformer assembly is plugged into an
ordinary 120 V ac outlet, and the smaller plug goes Into
the POWER IN jack on the side of the console unit.
A cable and plug attached to the rear of the console
goes to the antenna terminals on a standard tv receiver. If
you plan to use the tv for viewing ordinary programming,
that antenna connection should be made through an
antenna switch that is provided with the basic unit.
To get this configuration into operation:
1. Turn on the tv set.
2. If you are using the antenna switch, set the switch to
its COMPUTER position.
3. Turn on the computer console, using the POWER
switch located on the left-hand side of the unit.
4. Set the CHAN switch on the side of the console for
either Channel 2 or 3, and match the tv channel
selector accordingly. Use the channel that can be
tuned for the lesser amount of outside interference.
When all is going well, the tv will show a blue back-
ground color, a lighter blue READY message, and a light-
blue square just below the message. At that time, the sys-
tem is ready to operate in ATARI BASIC.
If you have an ATARI 800 system and wish to work with a
monitor unit instead of a tv receiver, the hardware arrange-
ment is somewhat simpler. You have no need for the
antenna switch nor the tv cable coming from the back of
the console. Simply run the monitor cable from the 5-siot
MONITOR jack on the side of the console to the video
and audio input terminals on the monitor. The CHAN
selector switch setting is not relevant at all.
Minimum System Plus Program Recorder
Fig. 1-5 shows the minimum system configuration as
extended to include the ATARI 410 program recorder.
Using the program recorder enables you to save programs
on the magnetic tape in a standard tape cassette, and then
reload those programs at some later time.
16
CONVENTIONAL
TV RECEIVER
"■
O
==
CONVENTIONAL TV
ANTENNA OR CABLE
Fig. 1-5. Connectiondiagramforan ATARI Home Computer system
that is using the 41 program recorder.
Connect the program recorder to the PERIPHERAL jack
on the side of the console unit, using a cable assembly that
is provided for that purpose.
The start-up procedures are identical to those already
described for the minimum system.
Minimum System Plus One Disk Drive
A single ATARI 810 disk-drive unit is connected to the
console in the same way that the program recorder is —
directly to the PERIPHERAL jack. The start-up procedure
includes two additional steps, however.
First, when installing a disk-drive, make certain that the
slide switches on the back of the drive unit are set for
drive No. 1.
17
Turn on the tv receiver or monitor, and then insert a
diskette into the disk-drive unit. That diskette must be
properly formatted and include the DOS system pro-
gramming (the DOS system disk supplied with the disk
assembly will include that programming).
Next, turn on the disk-drive unit. Do not have the con-
sole unit turned on at this time. Only when the disk drive
stops running (the red light will go out) should you turn
on the console.
A Common Multiple-Peripheral System
Fig. 1-6 illustrates one of the most common ATARI config-
urations: the basic console unit, a tv receiver or monitor, a
single disk-drive unit, a model 850 serial interface module,
and a printer.
The start-up sequence for such arrangements is quite
critical. In this particular case:
1. Turn on the tv set or monitor.
2. Insert a diskette containing the DOS system pro-
gramming into the disk-drive unit.
3. Turn on the disk-drive unit and wait for the drive to
stop running.
4. Turn on the 850 serial interface module.
5. Turn on the printer.
There are many other possible configurations that can
be far more complex that these— using multiple disk
drives, for instance. Consult the manuals that are supplied
with the peripherals for exact details.
Generally speaking, however, the turn-on procedure
follows the same general plan: turn on the tv or monitor,
boot DOS by turning on disk-drive 1, turn on the console,
turn on the interface module, and turn on peripherals that
are connected through the interface module.
18
CONVENTIONAL
TV RECEIVER
VHP ANTENNA
TERMINALS
CONVENTIONAL TV
■ ANTENNA OR CABLE
POWER P<
IN
DWER
JNIT
' — z
TO
PERIPHERAL
r-V 120 VAC
/ OUTLET
/I
n
CHI
ATARI
PRINTER
ATARI 850
SERIAL
INTERFACE
Fig. 1-6. Connection diagram for an ATARI Home Computer system
that uses a single 810 disk drive, an 850 serial interface
module, and an ATARI Home Computer printer.
SOME SPECIAL KEYBOARD OPERATIONS
When an ATARI system is properly configured and initial-
ized, you should see a blue screen, BASIC'S READY
prompting message, and the cursor (the light blue square
under READY). That means that the system is ready for
commands from the keyboard.
19
Much of the material remaining in this book deals with
the nature of those BASIC commands. During the course
of working with those commands, however, it is often
necessary or desirable to execute some special keyboard
functions.
Some Control Keys
Most of the ATARI computer keyboard is identical to that
of a conventional typewriter. There are some special keys
and key functions that are generally irrelevant for ordinary
typing operations, but quite important for operating a
computer.
The ■iiaiaifil key is perhaps the most-used control key.
You must strike the control key whenever you want the
computer to execute a command that you've given it in a
typewritten form. When you are ready to executes BASIC
program, for example, y ou should type RUN on the key-
board, and then strike the ■aaiim« key to get the comput-
er to read and execute the command. The special control-
key operation s describe d in this section do not have to be
followed b yaliai aigl keystroke, however.
The two Kiiliaa keys serve much the same function as
the shift keys on an ordinary typewriter. There are some
differences, though. For instance, when you turn on the
ATARI system, you find that all letters of the alphabet are
p lanted t o the screen in an upper-case format. Depressing
a ESDO key while typing letters of the alphabet will cause
the system to print lower-case letters. That is just the
reverse of ordinary typewriters.
It is possib le to change the format by striking the
■lilihlViTia key. Having done that, all letters of the
alphabet are normally printed in their lower-case form;
and you must hold down one of the E3SI keys in order
to print upper-case letters.
To retur n to no rmal upper-case printing, hold down
one of the BiUU keys and strike the E^BSMM key
again.
20
The ■•fiiM.'Mwvia key affects only the letters of the
alphabet. That is another feature that makes the computer
different from a typewriter. No matter what the ■«Ma«M
BE3S^ setting might be, striking the HI key will print a
3, and holding down a ESQI key while striking the
key will print a " to the screen.
As mentioned earlier, the screen shows light-blue char-
acters against a darker blue background. You can reverse
the situation by striking the ATARI logo key — the one
marked with the familiar ATARI symbol. Strike that key
again, and the colors return to normal.
The ■*■■;!■ key, in effect, multiplies the number of key
functions that are available. Holding down the |!UU9 key
while striking another key often changes its function.
Throughout this book, a statement such as ■«■■:!««
means: hold down the ISUiU key while striking the Dl
key.
The ■Ma»*iM:yj«i:^« key is intended for programmers
who make typing errors. Hold down a ■«-"»■ key while
striking the ■»ia«aiM:riiw:^« key, and the computer de-
letes the entire line of text that is marked by the cursor.
Strike the ■»ia«*i«:fiTw:»« key without holding down a
»"■"** key, and the computer erases the character under
the cursor and moves it one column, or character loca-
tion, to the left.
The II2S13BH key will create a blank line for inserting
a new line of printed text — if you are holding down a
»^="*" key at the time. Make that keystroke without hold-
ing down one of the "^-'lai* keys, and the computer will
print the > symbol on the screen. To insert a single charac-
ter into a line of text, do a BiiBISSiSI operation.
The same general idea applies to the IHIJ-lsi— key.
Hold down a EUliafl key while striking the mJJ.I— key,
and the computer will clear the screen and set the cursor
to its home position in the upper left-hand corner of the
screen.
21
The four arrow keys located near the right side of the
keyboard allow you to move the cursor to any desired
point on the screen. In order to use them, however, you
must b e holding dow n the ISUiia key at the same time.
The ■miyniaa key serves the purpose of the tab
functions on an ordinary typewriter. Strike that key alone,
and the cursor will jump to its next horizontal tab location
on the screen. You can set new tab positions by first set-
ting th e cursor to the d esired tab position, and then strik-
ingthe B«»a*M*^^i* key while holding down one of the
Klililfl keys. Finally, yo u can c lear a current tab setting by
holding down both th e mia key an d one of the E3IO
keys while striking the IrfliMd^JiWa |<ey.
The I'lHTiilW key is used for stopping the execution of a
program.
The laasi key, like the KlliU key, changes the normal
functio ns of other keys. Whereas you must hold down the
■SUilS key while striking another key, you use the 1339
key in sequence: first strike the 13391 key, release it, and
then strike another key. The special iSUilS and I^QI
operations are described in later discussions in this book.
SOME SCREEN EDITING FEATURES
When working in BASIC, it is often necessary to change
some of the material printed in the program. The ATARI
system offers some program-editing features that make
the task much simpler.
The most important point to bear in mind is that the
ATARI screen is "live." That is to say, what you see on the
screen is what is actually in program memory. So change
something on the screen, and you also change the pro-
gramming as well.
22
This leads to the notion of editing a program by first
listing the relevant portions of it on the screen, using the
■SUilS-arrow keys to position the cursor, and then using
the insert/delete operations to change the text. Once you
have changed a line of programming, you strike the
■aaiiiMk^ri Icey in order to enter that change into memory.
WORKING WITH THE PROGRAM RECORDER
The ATARI 410 program recorder offers the most econom-
ical means for saving and loading programs and other
kinds of data. When saving programs and data by means of
the program recorder, the ATARI system converts the
information into audio tones that can be easily recorded
on magnetic tape; specifically on the narrow tape in ordi-
nary audio cassettes. And when loading previously saved
information, the program recorder reproduces the audio
tones, and the system converts them back into meaningful
computer data for the system's RAM.
It is possible, and certainly economically attractive, to
save more than one program on a single cassette. The only
problem is being able to find the segment of tape that
contains the desired program. For that reason, the ATARI
program recorder includes a numerical tape-counter
mechanism.
Whenever you are starting to work with a cassette, it is a
good idea to rewind it to the beginning and reset the tape
counter to zero. Then when you are ready to record a
program from the ATARI computer memory, note the
tape-counter reading before starting the recording opera-
tion. Write down that reading as well as a short, but mean-
ingful, description of the program. Then note the tape-
counter reading at the end of the recording session so that
you will know where to begin recording another program
on the same tape at some later time.
23
If you wish, you can listen to the audio tones during a
data recording or playback session. If you are using an
ordinary tv set as a screen monitor for the system, simply
turn up the volume control; or if you are using a monitor,
make sure that the audio plug is inserted into the moni-
tor's audio input jack, and turn up the volume control on
that unit.
Connecting the Program Recorder to the System
Fig. 1-5 shows the arrangement of the system if you are
using no peripheral devices other than a tv or monitor and
the program recorder. The program recorder plugs di-
rectly into the peripheral connector on the side of the
ATARI console unit.
If the program recorder is used in conjunction with sev-
eral other peripheral devices, it must be connected to the
system through a serial interface module, and it must be
the last peripheral in line.
Saving and Loading Programs With the Program
Recorder
The most commonly used command for saving BASIC
programs on cassette is CSAVE; and getting a BASIC pro-
gram from tape and into the ATARI computer is by means
of the CLOAD command.
To save a BASIC program on the program recorder, first
use the FAST FORWARD and REVERSE keys on the pro-
gram recorder to find the end of any programming that
currently exists on the tape. Note the reading on the
recorder's tape counter for future reference.
Set the recorder to its record mode by depressing both
the RECORD and PLAY levers; and immediately follow
that by entering the following command at the ATARI
console:
CSAVE
24
The recording session will require at least 30 seconds.
Turn up the volume on the tv set or monitor if you want to
listen to the steady whistle of the leader and the obnox-
ious sound of the data being transferred. Whether you
wish to listen to the sounds or not, you know that the
recording session is done when the BASIC prompt symbol
and READY message reappear on the screen. Turn off the
program recorder at that time.
You can load a BASIC program from cassette tape to the
atari's program memory with the help of the CLOAD
command. You must, however, first cue the tape to the
beginning of the program you want to load.
Assuming that you have saved the reading from the tape
counter as suggested for the CSAVE routine, find that
location on the tape by entering the CLOAD command at
the console and, upon hearing two beeps from the con-
sole loudspeaker, cue the tape to the beginning of your
program.
Next, depress the PLAY lever on the program recorder
and strike any key on the ATARI console (except the
■tiaatiM key) — that will begin the loading operation. You
can listen to the audio activity through the loudspeaker of
the tv or monitor unit; and if you do, you should hear a
rather long, steady leader tone, followed by a lot of whis-
tles and beeps that represent the data. The loading session
is done when the sounds end or, if you choose not to
listen to them, when the BASIC cursor and READY mes-
sage reappear on the screen.
As is the case with most program-recorder operations,
the system automatically selects lOCB Channel 7 for this
one. That channel must not be open for any other pur-
pose at the time you execute a CSAVE or CLOAD com-
mand. If you run into difficulties in this regard, try execut-
ing an LPRINT or CLOSE command before doing the
CSAVE or CLOAD.
See Chapter 6 for some alternative techniques and
commands for saving and loading all kinds of data.
25
ROUTINE DISK OPERATIONS
Fig. 1-6 shows a disk-drive unit connected to the ATARI
system. When using more than one disk drive, determine
the proper installation procedures from the user's manual.
Assuming that DOS is properly booted as described earlier
in this chapter, typing DOS and striking the 1:IA<II;»W key
brings up the DOS menu — it is a convenient guide to run-
ning variety disk utility operations. See the two common
versions of the DOS menu in Chart 1-1.
Chart 1-1 . Two Common Versions of the DOS Menu
DOS Version 1 .0
A.
DISK DIRECTORY
1.
FORMAT DISK
B.
RUN CARTRIDGE
J.
DUPLICATE DISK
C.
COPY FILE
K.
BINARY SAVE
D.
DELETE FILE(S)
L.
BINARY LOAD
E.
RENAME FILE
M.
RUN AT ADDRESS
F.
LOCK FILE
N.
DEFINE DEVICE
G.
UNLOCK FILE
0.
DUPLICATE FILE
H.
WRITE DOS FILE
DOS Version 2.0S
A.
DISK DIRECTORY
1.
FORMAT DISK
B.
RUN CARTRIDGE
J.
DUPLICATE DISK
C.
COPY FILE
K.
BINARY SAVE
D.
DELETE FILE(S)
L.
BINARY LOAD
E.
RENAME FILE
M.
RUN AT ADDRESS
F.
LOCK FILE
N.
CREATE MEM. SAVE
G.
UNLOCK FILE
0.
DUPLICATE FILE
H.
WRITE DOS FILE
Displaying the Current Disk Directory
Execute the DOS command from the keyboard, and then
select menu option A. The system will respond by printing
this prompting message:
DIRECTORY— SEARCH SPEC, LIST FILE?
26
From there, you can see the complete listing of files on the
current disk by striking the ■"*"'"" key twice in succes-
sion or entering this response:
D1:
If you have more than one disk drive, you can see the
directory for drive number 2 by responding to the prompt-
ing message by entering this:
D2:
And if you have an ATARI printer connected to the
system and want to print a disk directory to it, modify your
response to this form:
D1:,P
The directory includes the filenames and the number of
disk sectors each occupies. The directory concludes with a
message that indicates the number of unused sectors.
A single diskette can hold as many as 64 files in its direc-
tory, and that many filenames cannot fit onto the display
screen. It is possible to search and display the name of a
single file by modifying your response to the prompting
message to include the desired filename.
Suppose, for example, you want to know whether or
not a filename SILLY. FUN is on the current disk. When you
see the prompting message, respond by entering a:
D:SILLY.FUN
If, indeed, that file is present, the system will print the
name again, along with the number of sectors devoted to
it. If the file is not on the current disk, the system will
simply print the number of free sectors remaining on the
disk.
It is also possible to list just certain kinds of file names.
Perhaps you want to list only those files that end with the
extension .BAS. In that case, respond to the prompting
message with this sort of entry:
D:*.BAS
27
In a manner of speaking, the asterisk tells the system to
work with any combination of letters and numerals in that
part of the file name.
By way of another example, suppose that you want to
see the directory of all file names that begin with the let-
ters ALT. This sort of response will do that for you:
D:ALT*.*
Returning to BASIC
The all-around safest way to return to BA SIC from the
DOS menu is to strike the ■aMaiamwHaaaw key. Alterna-
tively, you can elect menu item B, but there is a chance
that you will lose some BASIC programming that is resi-
dent in the system.
Actually the purpose of DOS menu item B is to return
program control to the resident cartridge. If that happens
to be the BASIC cartridge, the system begins running in
BASIC. Or if it is a special language or game cartridge,
selecting menu item B begins execution of that program.
Copying Files to the Same Disk
DOS menu item C provides a means for copying files and
programs onto their own disk. This feature is most often
used for generating backup copies on the same diskette.
Perhaps you are planning to revise a program that already
exists on the disk. You want to save the original version,
but create a copy that you can modify. That is the primary
application of DOS menu selection C.
Upon entering that selection, you will see this prompt-
ing message:
COPY FILE— FROM.TO?
28
The system is expecting you to enter two filenames separ-
ated by a comma. The first name is one that is to be copied
and already in the disk directory. The second name is the
name of its copy. The two names must be different; per-
haps different only in the extension, but nevertheless dif-
ferent (see the general rules for composing disk file names
described later in this chapter).
So if you want to copy a file that already has the name
BIGTIME and give that copy the name of BIGTIME.BAK,
this is the sort of response you should enter:
BIGTIME.BIGTIME.BAK
If you are using DOS version 2.0S and you have a BASIC
program resident in the ATARI system, you will see the
following kind of prompting message before the actual
copying operation takes place:
TYPE "Y" IF OK TO USE PROGRAM AREA
CAUTION: A "Y" INVALIDATES MEM.SAV
The idea here is that the copying procedure might de-
stroy any BASIC programming that is resident in the sys-
tem at the time. If you are willing to lose that program-
ming, then a "Y" response is appropriate. Otherwise, it is
better to respond with an "N" and save the resident pro-
gram on disk before attempting the copying routine
again.
If you are using more than one disk drive, menu option
C allows you to copy files from one disk to the other. In
this instance, you can use the same file name if you
choose, just making sure to indicate the source and desti-
nation drives in your response. For example:
COPY FILE— FROMJO?
D1:BIGTIME,D2;BIGTIME
That will copy a file named BIGTIME from drive 1 to drive 2.
29
You can also use global (or "wild -card") file names
under the file-copying option. Suppose that you want to
transfer ail of the SYS, or system, routines from drive 2 to
drive 1. The appropriate response to the prompting mes-
sage is:
D2:*.SYS,D1:*.SYS
Or if you want to copy all files beginning with FUS to the
same disk, but add a BAK extension, the appropriate entry
is:
FUS*.*,FUS*.BAK
Finally, there is the option of merging disk files — adding
the content of a source file to the end of an existing desti-
nation file. The only catch is that both files must have been
saved in an ATASCII format (see Chapter 6). The general
syntax of such an operation is:
source,des(/A
where source is the file name for the source file, and dest
is the file name of the destination file. The suffix /A is what
prevents the source file from completely writing over the
destination file.
Deleting Files
There is little point in cluttering valuable disk space with
files and programs that are no longer of any use. DOS
menu option D allows you to delete, or erase, any un-
wanted programs or files.
Upon selecting menu option D, the system displays this
prompting message:
DELETE FILE SPEC
You should respond by entering the name of the file to be
deleted. And if you enter a file name that exists on the
disk, the system will ask you whether or not you really
want to delete it:
TYPE "Y" TO DELETE . . .
30
If you change your mind about deleting the file, simply
respond by entering an N. Respond with a Y, and the
system will delete the file you named.
Use the asterisk option to cite global file names. The
extreme case is that of deleting all the files on a disk. To do
that, respond to the original prompting message by
entering:
and enter a Y in response to the "are-you-sure" prompt-
ing message. Herein lies a certain problem: the system
brings up the "are-you-sure" message for every program
or file that it is about to delete, it can be quite trouble-
some to respond with a Y for each one to be deleted. The
way around that inconvenience is to append the *.*
response with /N. For example:
*.*/N
The /N overrides the "are-you-sure" prompting feature.
Renaming Existing Files
DOS menu option E gives you an opportunity to rename
an existing file. Elect that option, and you will see this sort
of prompting message on the screen:
RENAME— GIVE OLD NAME,NEW
The general idea is to respond by citing the old file
name followed by the revised name. If the old name does
not exist, or if that file is locked, the system returns an
error code. But you are in trouble if you inadvertently cite
a NEW name that is identical to one that already exists on
the disk. You end up with two different files having the
same name, and the system has no way of distinguishing
them.
31
Locking Files
DOS menu option F allows you to lock a file so that it
cannot be changed or renamed as long as the file remains
locked. Responding with that menu selection brings up
this prompting message:
WHAT FILE TO LOCK?
Simply respond by entering the name of the file— one that
already exists in the directory.
You can use the global option to lock all files having a
specified name or extension in common. It is a good idea,
for example, to lock all SYS files so that they cannot be
inadvertently changed, erased, or renamed. Do that by
responding with:
*.SYS
Unlocking Files
There are instances where it is necessary to unlock a pre-
viously locked file; perhaps to modify it or erase it alto-
gether. DOS menu option G offers this feature. Selecting
that option brings up this sort of prompting message:
WHAT FILE TO UNLOCK?
Simply respond with the name of the file to be unlocked,
and the computer will take care of the task for you.
Copying DOS files
A finished disk of BASIC programs ought to contain the
system files that boot DOS for you. That circumvents the
troublesome need to boot DOS with a special systems disk
and then replacing it with your working BASIC disk. Elect-
ing DOS menu item H does that for you. The mechanical
procedures are different for DOS 1.0 and 2.0S.
If you are using version 1.0, the system prints this
prompting message:
TYPE "Y" TO WRITE NEW DOS FILE
32
Insert a properly formatted disk into drive number ^, and
respond by entering a Y. That will copy the DOS.SYS pro-
gram to the disk.
If you are running under DOS version 2.0S, the system
prints this prompting message:
DRIVE TO WRITE FILES TO?
Insert a properly formatted disk into one of the disk-drive
units, and respond with the drive number. The system
brings up a TYPE "Y" TO WRITE prompting message; and
if you respond with Y, it copies DOS.SYS and DUP.SYS to
the designated disk.
Formatting a Disk
DOS menu item I is the one that formats a new disk for
you. Every disk must be formatted before it can be of any
practical use. Upon entering that option, the system
responds with this sort of prompting message:
WHICH DRIVE TO FORMAT
Insert the disk to be formatted into one of the disk-drive
units, and respond to the prompting message with the
disk-drive number. The system will then display a TYPE
"Y" TO FORMAT message to confirm that everything is
set up properly. If that is the case, enter a Y, and the
system will format the disk for you.
Duplicating an Entire Disk
DOS menu selection C allows you to copy disk files and
programs one at a time. Menu selection J copies an entire
disk. Selecting DOS menu item C brings up this prompting
message:
DUP DISK— SOURCE, DEST DRIVES?
33
The general idea is to respond with the disk-drive number
of the disk to be copied (the source disk), a comma and
the disk-drive number of the new copy (the destination
disk). The appropriate response and operations from that
point are slightly different, depending on whether you
have one or two disk drives available.
If you have just one disk drive available, you must
respond to the prompting message by entering 1,1. That,
in effect, says that the source and destination disks will
both be in drive 1. Obviously you cannot fit two disks into
the same drive unit, so the system will respond with this
message:
INSERT SOURCE DISK, TYPE RETURN
Insert the disk to be copied and strike the Irl^^HilW key.
The system will load up the ATARI RAM with disk data;
and when it is full, you will see this message:
INSERT DESTINATION DISK, TYPE RETURN
Respond by replacing the source disk with a clean and
formatted disk, and striking the ■aMMinii^w key. The system
will then load the most recent blocks of data to that disk.
When using a single disk drive in this fashion, it is often
necessary to alternate the source and destination disks
several times. This swapping operation will come to an
end only after the entire contents of the source disk is
copied to the destination disk.
Things are a lot simpler for the operator when two disk
drives are available. Electing the disk copy operation, as
before, brings up this prompting message:
DUP DISK— SOURCE,DEST DRIVES?
Respond by entering two different disk-drive numbers:
the source followed by the destination. Suppose that you
want to copy the content of the disk in drive 1 to a fresh
disk in drive 2. That being the case, the appropriate
response to that prompting message is:
1,2
34
After making that response, the system will print:
INSERT BOTH DISKETTES, TYPE RETURN
The computer then takes over the copying task com-
pletely. Usually you will find the disk drives running
alternately through several cycles.
Getting MEM.SAV Onto a Disk
When you are working under DOS version 2.0S, electing
menu item N will cause the system to generate the
MEM.SAV file onto the disk in drive number 1. (Although
the DOS version 1.0 lists an operation for menu item N, it
is not functional.)
Most of the DOS menu operations use generous por-
tions of the RAM area. That is not a problem if you have
no vital programming in RAM at the time. But if you want
to preserve a resident BASIC program you either have to
save that program on disk before beginning DOS menu
operations (the only option available under DOS version
1.0) or including the MEM.SAV routine on the current
disk.
If MEM.SAV is on the current disk, the system will
automatically use it to save portions of RAM-based pro-
gramming that might otherwise be lost. Then when you
leave the DOS menu operations, MEM. SAVE returns the
original programming to RAM.
An Alternative File-Copying Operation
Menu item O is most useful when it is necessary to copy a
file from one disk to another when you have just one disk
drive unit. Menu item C lets you copy from one disk drive
to another, or on the same disk if the file names are some-
how different; but that selection cannot copy the same
file name on two different disks that are alternately
inserted into the same drive unit.
35
Upon selecting DOS menu item O, the system prints
this prompting message:
NAME OF FILE TO MOVE?
Respond with the file name of the file to be copied. Hav-
ing done that, the system will prompt you to insert the
source disk and strike the ■:I^JII:1« key. After that, it
prompts you to replace the source disk with the destina-
tion disk— and strike the BHEEia key. If the file is a fairly
long one, you will have to switch the source and destina-
tion disks several times.
The Machine-Language Options
DOS menu items K, L, and M deal with machine-language
program operations. Chapter 6 describes these operations
in detail.
Saving and Loading Programs With the Disk Drives
Starting with a properly formatted diskette, simply insert
the diskette into a drive unit and enter a command of this
general form:
SAVE 'D[n]':fi7ename[.ext]
That command includes a couple of optional expressions
that are included in brackets. Expression n is necessary
only when (1) using more than one disk drive and (2) you
want to save the program on a drive other than drive No.
1. The filename is not optional, and it must follow these
general rules:
1. It must be composed of nothing but numerals and
capital letters.
2. It must be no more than eight characters long.
3. It must begin with a letter of the alphabet.
36
The file name extension exf is optional. It can be com-
posed of no more than three characters, but they can be
all numerals, all upper-case letters, or any combination of
the two. The extension is separated from the file name
with a period.
Normally,, the extensions are used for specifying the
type of file being saved. The following list suggests some
commonly used file extensions and their meaning.
.ASM — an assembly language source file
.BAS — a BASIC program
.BAK — a backup file
.DAT— a DATA file
.LST — an ATASCII-coded program file
.OBJ — an object-code file
.SCH or TMP— a "scratch," or temporary file
.TXT— a text file
Avoid using the SYS file extension, however, because
the ATARI operating system uses that one for much of its
own internal programming.
Executing the SAVE command will cause the disk drive
to run and the upper red lamp to turn on. The routine is
complete when the disk drive stops running and the
uppermost lamp goes off.
You can load a tokenized BASIC program from the disk
system by using a LOAD command of this form:
LOAD"D[/7]:///eA7a/77e[.exr]"
where n is the optional disk-drive number, filename is the
name of the file to be loaded, and exf is the optional
extension.
Assuming that the designated file exists on the current
diskette, executing the LOAD command will cause the
disk system to run until the program is completely loaded.
LOAD used lOCB Channel 7. if Channel 7 is already
open for some other purpose when you execute a LOAD
"D: command, DOS will automatically close and reopen
Channel 7 for disk I/O operations.
37
Chapter 2
ATARI BASIC Notation, Rules,
and Limitations
Most people begin familiarizing themselves with the
ATARI 400/800 systems through the BASIC programming
language, so this chapter introduces some of the funda-
mental concepts of that language. Although it is assumed
that you are running the system with the ATARI BASIC
COMPUTING LANGUAGE cartridge (CXL4002) connected
into the single cartridge slot (Model 400) or the left-
cartridge slot (Model 800), many of the principles apply
equally well to BASIC for other computers.
NUMERIC AND STRING CONSTANTS
In terms of BASIC programming, a constant is a specific
value; and as described in the following sections, con-
stants can be classified as either numeric constants or
string constants. Knowing how to work with numeric and
string constants can eliminate a lot of undesirable and
puzzling programming effects.
39
Numeric Constants
A numeric constant is some fixed numerical value. Here
are a few numeric constants that are expressed in rather
familiar forms:
23 -212 1.6888 9.9999 1432000
Numeric constants can be very small or very large
numbers, they can be positive or negative, and they can
be whole numbers or numbers having decimal parts. Just
ordinary number values— that is all numeric constants are.
There are a few special rules, limitations and forms of
notation that apply to numeric constants in BASIC. For
one, large numbers must not use commas in the conven-
tional fashion; in fact they must not use commas at all. So
if you wish to express a value of one million in BASIC, you
must enter it as 1000000, and not as 1,000,000.
In keeping with the usual arithmetic convention, neg-
ative-valued numeric constants are preceded by a minus
sign, while positive values can be expressed with a plus
sign or no sign at all. if you enter a PRINT -128 command,
for example, ATARI BASIC will respond by printing - 128
on the screen. But if you enter a PRINT +128 command,
BASIC will exercise the no-sign option and print 128.
ATARI BASIC uses a number format called floating-
point notation. Among other things, that means it ex-
presses very large and very small values in terms of
powers-of-10, or scientific notation. Very large numbers,
in this context, are positive or negative numbers having
more than nine digits to the left of the decimal point; and
very small numbers are those between -0.01 and 0.01.
To see how ATARI BASIC handles very large values,
enter this command:
PRINT 12345678901
and you will see this response:
1. 2345678901 E+10
40
The PRINT statement specifies a positive constant that has
more than nine significant digits, and BASIC responds by
converting the value to a form of scientific notation. The E
+ 10 in that response represents x10'°— ten to the tenth
power.
The same general idea applies to small numeric values.
Enter this command:
PRINT 0.0001 2345
and ATARI BASIC will show this version:
1.2345E-04
That value in the PRINT statement is less than 0.01, so
ATARI BASIC automatically converts it to scientific nota-
tion, where E - 04 means 10".
There are some limitations on the range of numeric
values that can be expressed in ATARI BASIC, even when
using scientific notation; and that range is:
- 9.99999999E + 97 through 9.99999999E + 97
Furthermore, there is a range of values that is very close to
zero wherein a value will be automatically set to zero. That
range is:
- 9.99999999E - 98 through 9.99999999E - 98
Finally, there are not only limitations on the values of
numeric constants, but also on the number of significant
nonzero digits — nine of them. ATARI BASIC allows only
nine significant digits that are not zero; it accepts numbers
having more than nine significant digits, but it sets all dig-
its beyond the nine to zero.
The constant 123456789123456789, for example, has 18
significant digits, but ATARI BASIC will deal with it as
123456789000000000. There are still 18 significant digits, but
only the first nine have nonzero values. And as described
earlier, it will convert such values to scientific notation:
1.23456789E+17.
41
The same principle applies to fractional numbers. A
constant such as 0.00123456789123456789 has 20 significant
digits to the right of the decimal point. Eighteen of them
are nonzero digits, so ATARI BASIC will treat the number
as 0.00123456789 and display it as 1.23456789E-03.
Summarizing the limitations and conventions required
for numeric constants in ATARI BASIC:
• Large numeric values must not include commas.
• A negative sign ( - ) must precede a negative-valued
constant, but a plus sign ( + ) is optional for positive-
valued constants (ATARI BASIC will always print posi-
tive values without the plus sign).
• ATARI BASIC uses scientific notation for expressing
very large and very small numeric constants.
• ATARI BASIC will deal with only nine nonzero signif-
icant digits; any beyond that number will be set to
zero.
String Constants
Whereas numeric constants must be composed of mean-
ingful numeric values, string constants can be constructed
of any combination of letters, punctuation marks, special
symbols and numerals. What's more, string constants usu-
ally must be enclosed in quotation marks.
The following BASIC statement prints a string constant,
HELLO:
PRINT "HELLO"
The string constant in that instance is composed entirely
of upper-case letters of the alphabet and, as is usually the
case, the constant is enclosed in quotation marks. When
you execute that PRINT command, however, you will see
ATARI BASIC printing HELLO without the quotes.
As implied earlier, a string constant can be built from all
sorts of letters and punctuation. For example:
PRINT "Hello, there, you silly goose!"
42
The string constant in that case includes both upper- and
lower-case letters as well as some spaces and punctuation
marks. The only punctuation that doesn't work is the quo-
tation mark, itself; it is used to mark the beginning and
end of a string constant, and, therefore, cannot appear
within the string, itself. Most programmers cope with that
little difficulty by using apostrophes where quotes would
normally appear within a string.
Numerals that are included in a string constant are
treated as literal characters rather than numeric values.
You can prove that point with a simple demonstration.
First, treat the expression 1 + 2 as a string constant. In
other words, execute this statement:
PRINT "1+2"
The fact that you have enclosed the expression within
quotation marks means that the computer will interpret
the numerals as part of a string, and it will respond by
printing out a literal version of your string:
1+2
Next, execute this command:
PRINT 1+2
Omitting the quotation marks suggests that the numerals
are to be treated as numeric constants, and the computer
responds to that fact by printing the result of the summa-
tion operation:
The only limitation on the length of a string constant
(the number of characters included in it) is the amount of
available computer memory; however, it is a good prac-
tice to make a habit of dealing with 130 characters or less.
The reason for that limit, incidentally, is that it is the size of
the INPUT string buffer.
43
NOTE: There is a special string constant that contains no
characters whatsoever. It is defined by a pair of successive
quotation marks, "", and is called the null string.
Summarizing the rules and limitations for expressing
String constants:
• In most instances, string constants must be enclosed
in quotation marks. (The special exceptions will be
described in later discussions.)
• String constants may be composed of any characters
except a quotation mark.
• Numerals appearing within a string constant are
treated as literal characters rather than numeric
values.
• The recommended maximum length of a string con-
stant is 130 characters.
BASIC VARIABLES AND VARIABLE NAMES
Most arithmetic and control operations in BASIC make
reference to variables and, particularly, variable names. A
variable is an expression that can take on a wide variety of
different values— values that are assigned to variables
through the normal execution of a program. A variable
name is a set of one or more alphanumeric characters that
you, the programmer, devise yourself according to a few
simple rules.
NOTE: ATARI BASIC allows up to 128 different variables to
be used through the execution of a program.
BASIC uses two kinds of variables: numeric variables
and string variables. The following discussions point out
their differences.
44
Numeric Variables
Numeric variables and numeric variable names refer to
numbers or quantities. They are used in much the same
way that variables are used in ordinary algebra. This 2-line
program illustrates the use of a particular numeric
variable:
10 AX=200
20 PRINT AX
Line 10 assigns a numeric constant, 200, to a numeric vari-
able that has the name AX. Line 20 then prints the value
that is currently assigned to variable AX— a value of 200 in
this case. You could get the same overall result by
executing:
PRINT 200
but that limits the operation to printing a single value. The
advantage of using variables is that you can get this pro-
gram to print some other number by assigning a different
constant to AX in line 10. There is no need to adjust the
PRINT statement in line 20, because that statement refers
to the variable name in a general way and makes no spe-
cific reference to the constant value that is assigned at an
earlier time.
A BASIC programmer has a great deal of latitude, and
only a few rules to follow, when making up numeric vari-
able names:
1. A numeric variable name is composed of upper-case
letters of the alphabet and numerals through 9;
punctuation, including spaces and periods, is not
allowed.
2. There has to be at least one valid character in a
numeric variable name, of course, but the maximum
number of characters is limited only by the ability to
fit the name into the lines of BASIC programming
that use it. (Generally, it is good practice to use shor-
ter variable names, and yet make them long enough
to be meaningful.)
45
. Numeric variable names should not include the
words shown in the Reserved Word List, Chart 2-1.
(Although ATARI BASIC will usually accept variable
names from the Reserved Word List, there are many
instances where such names will cause an Error-
interrupt during the execution of a program.)
Chart 2-1 . ATARI BASIC Reserved Words List
ABS
IF
RESTORE
ADR
INPUT
RETURN
AND
INT
RND
ASC
LEN
RUN
ATN
LET
SAVE
BYE
LIST
SETCOLOR
CLOAD
LOAD
SGN
CHR$
LOCATE
SIN
CLOG
LOG
SOUND
CLOSE
LPRINT
SQR
CLR
NEW
STATUS
COLOR
NEXT
STEP
COM
NOT
STICK
CONT
NOTE
STRIG
cos
ON
STOP
CSAVE
OPEN
STR$
DATA
OR
THEN
DEG
PADDLE
TO
DIM
PEEK
TRAP
DOS
PLOT
USR
DRAWTO
POINT
VAL
END
POKE
XIO
ENTER
POP
EXP
POSITION
FOR
PRINT
FRE
PTRIG
GET
PUT
GOSUB
RAD
GOTO
READ
GRAPHICS
REM
NOTE: These words should not be used as variable names, nor should
they appear within variable names. It is possible to break that rule in
many instances, but a wise programmer will avoid the risks involved.
Here are some examples of valid numeric variable
names:
TRY AXIS MODEL1 NAMESFROMTABLE100
46
And here are some invalid numeric variable names:
try (uses lower-case words)
1TRY (begins with a numeral)
DARLING. SET (includes punctuation)
AND (uses a reserved word)
String Variables
String variables and string variable names refer mainly to
literal expressions, but they can also refer to combinations
of special control operations and graphics symbols. This
3-line program illustrates the use of a particular string
variable:
5 DIM AX $(10)
10 AX$="HELLO"
20 PRINT AX$
Line 5 dimensions a string variable, AX$, for 10 characters,
and then line 10 assigns a string constant, HELLO, to that
variable. Line 20 prints the constant that is currently
assigned to variable AX$— HELLO in this case. You could
get the same result on the screen by executing:
PRINT "HELLO"
but that limits the operation to printing a single string
constant. The advantage of using string variables is that
you can get this program to print some other string by
assigning a different constant to AX$in line 10. There is no
need to adjust the PRINT statement in line 20, because
that statement refers to the variable name instead of a
specific string constant that is assigned at an earlier time.
As with numeric variable names, a BASIC programmer
has a great deal of latitude, and only a few rules to follow,
when making up string variable names:
1. Every string variable name must end with a dollar-
sign ($) symbol.
2. A string variable name is composed of upper-case
letters of the alphabet and numerals through 9.
47
3. There has to be at least one valid character and a
dollar sign in a string variable name, but the maxi-
mum number of characters is limited only by the abil-
ity to fit the name into the lines of BASIC program-
ming that use it.
4. String variable names should not include the words
shown on the Reserved Word List, Chart 2-1. (Like
some numeric variable names, ATARI BASIC will
often accept variable names from the Reserved Word
List, even when appended with a dollar-sign symbol;
but the risk of causing an Error-interrupt during the
execution of a program makes it unwise to use such
names.)
Here are some examples of valid string variable names:
TRY$ AXIS$ MODEL1$ NAMESFROMTABLE10$
And here are some invalid string variable names:
*''y^ (uses lower-case letters)
^^^^^ (begins with a numeral)
DARLING. SET$ (includes punctuation)
MIX$MONEY$ (includes $ as punctuation)
^^^^ (uses a reserved word)
^^^^ (does not end with $)
NOTE: All string variables must be DIMensioned before
they are used in a program. See DIMENSIONING String
Variables and Numeric Arrays.
DIMENSIONING STRING VARIABLES
AND NUMERIC ARRAYS
BASIC'S DIM statement is always important for setting the
DIMension of numeric and string variables. It is especially
important in ATARI BASIC because it is required for estab-
lishing the maximum length of constants that are assigned
to every string variable in the program. The DIM state-
ment also sets up subscripted numeric variables and mul-
tidimensional numeric arrays. In spite of appearances to
48
the contrary, however, ATARI BASIC does not support
subscripted string variables nor string arrays.
DIMensioning String Variables
Every string variable that is used in an ATARI BASIC pro-
gram must be dimensioned with respect to the maximum
number of characters they are to contain. The dimension-
ing operation must occur prior to using the string varia-
bles, and it should occur just one time through the execu-
tion of the program.
Suppose that you anticipate using a string variable PY$ in
a program, and you think that any constants assigned to it
will contain no more than 10 characters. The appropriate
dimensioning statement is:
DIM PY$(10)
Because the dimensioning statements must occur prior
to any reference to the corresponding string variables,
most programmers make it a habit of placing the DIM
statements very early in the program — often in one of the
very first lines. So it isn't at all unusual to see the first
operational line in an ATARI BASIC program looking
something like this:
10 DIM A$(l), XE$(20), F$(6)
Having done that, string variable A$ will work with 1
character, XE$ will work with up to 20 characters, and F$
will work with as many as 6 characters.
The program will work, even if it happens that a dimen-
sioned string variable picks up more characters than is set
aside for it. In such cases, the computer simply truncates,
or cuts off, the string after the dimensioned number of
characters has been reached. The following program illus-
trates that point:
10 DIM NA$(5)
20 NA$="SOMETIMES"
30 PRINT NA$
49
Line 10 dimensions string variable NA$ for a maximum
of 5 characters, but line 20 assigns a string constant that has
9 characters in it. When line 30 prints the current string
constant that is thus assigned to NA$, it will show only the
first 5 characters: SOMET.
In actual practice, it is often inconvenient, and some-
times impossible, to determine the maximum number of
characters that will ever be assigned to a given string vari-
able. The temptation in such instances is to go overboard,
and dimension the variable at some large figure; say, DIM
X$(200). That should be avoided wherever possible, how-
ever, because the dimensioning operation reserves
memory space for the string characters; and using need-
lessly large dimensioning values uses up memory that
might be put to better use.
Incidentally, a CLR statement within a program clears all
previous dimensioning specifications. That can, in effect,
make it possible to redimension a string variable during
the course of a program. But CLR makes it necessary to
redimension all string variables to be used and sets the
DATA pointer to the first item in the lowest-numbered
data list, in other words, the notion of using a CLR state-
ment to redimension a variable during the execution of a
program is of questionable value.
Summarizing the procedures for dimensioning string
variables:
• All string variables must be dimensioned with regard
to the maximum number of characters they can
handle.
• String variables must be dimensioned prior to using
them, generally in one of the first lines of pro-
gramming.
• String variables cannot be dimensioned more than
one time during the execution of a program unless a
CLR statement is first used to zero-dimension all pre-
viously dimensioned variables.
50
• Assigning a string constant that has more characters
than is specified by the corresponding DIM state-
ment simply truncates the string.
Subscripted Numeric Variables and Arrays
The DIM statement in ATARI BASIC serves two entirely
different purposes for string and numeric variables. As
described in the previous section, every string variable
cited in a program must be DIMensioned according to the
maximum number of characters expected for its string-
constant assignments. Numeric variables, on the other
hand, do not have to be dimensioned unless they are to
be used as subscripted or multidimensional array varia-
bles. Whereas this simple string routine will not run with-
out the benefit of the DIM statement in line 10:
10 DIM A$(1)
20 A$="G"
30 PRINT A$
the following numeric program runs quite well without
any prior dimensioning of variable N:
10 FOR N=OTO 100
20 PRINT N;
30 NEXT N
Subscripted numeric variables or arrays must be dimen-
sioned prior to using them, however.
Generally speaking, subscripted numeric variables serve
the same purpose as their counterparts in conventional
algebraic notation. A mathematics or physics textbook, for
example, might show some subscripted variables this way:
Y =Xl + X2 + X3 + X4
51
The idea is to indicate the sum of four different numeric
variables that are closely related, but are able to take on
different numeric-constant values. Because BASIC does
not use subscripted characters, it is necessary to indicate
those characters within parentheses. Here is the BASIC
form of the "textbook" equation just cited:
Y=X(1)+X(2)+X(3)+X(4)
A program cannot refer to such subscripted numeric
variables in ATARI BASIC without first dimensioning them
with regard to the largest-value subscript you intend to
use. So before it is possible to execute that BASIC state-
ment, the program must include a DIM X(4) statement.
The general form of a subscript dimensioning statement
is:
DIMnumvar(d)
where numvar is any valid numeric variable name, and d is
the largest subscript index to be used. Thus a typical line
of programming for dimensioning several subscripted
numeric variables might look like this:
10 DIMX{3), FE(20), YY(9)
That one will dimension subscripted variable X for four
variables— X(0) through X(3). By the same token, it dimen-
sions FE for subscripted variables FE(0) through FE(20), and
YY for YY(0) through YY(9).
The following program prompts you to enter four dif-
ferent numbers. After that, it displays the four numbers,
their sum, and their average. In this particular case, the
numeric values are assigned to subscripted variables N(0)
through N(3) by means of INPUT and assignment state-
ments within a FOR . . . NEXT loop.
It can be very helpful to realize that the execution of a
RUN command automatically sets any subscripted
numeric values to zero. That eliminates the need for zero-
ing them as one of the first steps in a program.
52
10 DIMN(3)
20 FORE=0TO3
30 PRINT "ENTER A NUMBER ";
40 INPUT X:N(E)=X
50 NEXT E
60 PRINT:PRINT
70 FOR E=0 TO 3
80 PRINT N(E),:S=S+N(E)
90 NEXT E
100 PRINT "SUM=";S
110 PRINT "AVE=";S/4
A numeric array is an extension of subscripted variables.
Instead of using just one subscripted index numeral,
numeric arrays use two or more of them. The traditional
foundation for arrays in BASIC are the matrices of modern
algebra.
A 3 X 3 algebraic matrix is often organized this way in
math-oriented books:
ai,i ai,2 ai,3
32,1 a2,2 a23
a3,i a3,2 a3,3
The two subscripted numerals that are separated by a
comma indicate the row, column locations. So variable a2,3
indicates the third element in the second row.
Such elements are expressed in BASIC by including the
index terms — also separated by a comma — within a set of
parentheses. For example:
A(1,1) A(1,2) A(1,3)
A(2,1) A(2,2) A(2,3)
A(3,1) A(3,2) A(3,3)
53
Those are examples of a 2-dimensional array for variable
A; and that variable would have to dimensioned as DIM
A(3,3). The dimensioning operation for an array must indi-
cate the largest value that is to appear in the corre-
sponding element locations. A statement such as:
DIMXE(10,5)
would set aside space for 66 different array values for
variable— row indices through 10, and column indices
through 5.
The maximum size of an array is limited only by the
amount of available RAM, but ATARI BASIC does not
allow arrays of more than 2 dimensions.
It is particularly important to realize that executing a
RUN command in ATARI BASIC does not automatically
set all elements in an array to zero. It does so for simple
numeric variables and subscripted numeric variables (1-
dimensional arrays); but not for 2-dimensional arrays. So
arrays not only have to be dimensioned early in the pro-
gramming, but they must be initialized as well.
Suppose that a program is using a 2-dimensional array
for variable G, where the row elements range from
through 4, and the column elements range from through
8. A suitable initialization routine looks like this:
10 DIM G(4,8)
20 FOR X=0 TO 4:F0R Y=0 TO 8
30 G(X,Y)=0
40 NEXT Y: N EXT X
The DIM statement in line 10 dimensions the array. The
remainderof the routine then uses nested FOR ... NEXT
loops to set all elements of the array (45 of them) to zero.
Of course there has to be additional programming in
order to make the operation meaningful, but at least this
gets matters under control at the outset.
54
OPERATIONS AND OPERATORS
Much of the computing and control activity of a computer
are determined by the nature of operators that are written
into the programs. There are just three families of opera-
tors: arithmetic, relational, and logical operators. This sec-
tion describes and compares those three families.
Arithmetic Operators
Most people who are attempting to learn something
about computer programming are well aware of the
application of arithmetic operators— special, well-defined
symbols that indicate a mathematical operation that is to
take place between two numeric constants or variables.
Table 2-1 lists the arithmetic operators that apply under
ATARI BASIC and, indeed, most other versions of BASIC.
Table 2-1 . BASIC'S Arithmetic Operators
Operator
Function
+
addition (sum)
_
subtraction (difference)
»
multiplication (product)
/
division (quotient)
^
exponentiation (power)
-
negation (change of sign)
It is easy to check out the function of these operators by
entering some simple commands that use them. The com-
puter, in effect, works like a calculator.
PRINT 2 + 3 will show the sum, 5, on the screen.
PRINT 2-3 will show the difference, -1, on the screen.
PRINT 2*3 will show the product, 6, on the screen.
PRINT 3/2 will show the quotient, 1.5, on the screen.
PRINT 3*2 will evaluate 3^ and show 9 on the screen.
PRINT 2*3 will evaluate 2^ and show 8 on the screen.
X = 2:PRINT -X will negate the value originally assigned
to variable X, and show -2 on the screen.
55
Relational Operators
Relational operators suggest the relative magnitudes of
numeric values or values assigned to numeric variables.
The operations apply equally well to string values and var-
iables, but their applications in that case are rather differ-
ent. In either case, the operators are generally meaningful
only when used in conditional, IF . . . THEN statements.
Table 2-2 shows BASIC'S family of relational operators.
Table 2-2. BASIC'S Relational Operators
Operator
Function
<
less than
>
greater than
—
equal to
<-
less than or equal to
> —
greater than or equal to
<>
does not equal
Like the arithmetic operators, most of the relational
operators look like their counterparts in most math-
oriented text. The not-equal is the only one that is differ-
ent; it is most often shown as 7^ in noncomputer literature.
The following programming routines let you observe
the function of BASIC'S relational operators.
1 . The less-than operator:
10 X=1
20 IFX< 10 THEN 40
30 END
40 PRINT X;
50 X=X+1
60 GOTO 20
The less-than conditional statement in line 20 allows the
program to print the current value of X only as long as that
value is less than 10. The program, in other words, prints
integers 1 through 9, inclusively.
56
2. The greater-than operator:
10 X=1
20 IFX>9THEN END
30 PRINT X;
40 X=X+1
50 GOTO 20
That program also prints integer values of X in the range
of 1 through 9. Line 20, however, uses a greater-than
operator to determine when the current value of X
exceeds 9 and, consequently, brings the program to an
end.
3. The equal-to operator:
10 X=1
20 IFX=10THEN END
30 PRINT X;
40 X=X+1
50 GOTO 20
The routine prints integers 1 through 9, and comes to an
end when the equal-to condition in line 20 is satisfied.
4. The less-than-or-equal-to operator:
10 X=1
20 IFX< 10 THEN 40
30 END
40 PRINT X;
50 X=X+1
60 GOTO 20
This is yet another way to print integers from 1 through
9. In this case, the program continues printing those
integers as long as X is less than 10 as determined by the
conditional statement in line 20.
57
5. The greater-than-or-equal-to operator:
10 X=1
20 IFX>=10THENEND
30 PRINT X;
40 X=X+1
50 GOTO 20
The end of the integer-printing operation is detected by
the greater-than-or-equal-to operator in line 20.
6. The does-not-equal operator
10 X=INT(10*RND(1))
20 PRINT "GUESS A NUMBER BETWEEN AND 9 "
30 INPUT N
40 IF N <> X THEN PRINT "NOPE";GOTO 20
50 PRINT "THAT'S IT!"
Line 10 assigns a randomly generated integer value in
the range of through 9 to variable X. Lines 20 and 30 then
pronnpt you to enter your guess at that number and, sub-
sequently, assign it to variable N. Line 40 compares the
current values of N and X; if they are not equal, then the
program prints NOPE and loops back to line 20 to give you
another chance. But if it turns out that N is indeed equal to
X, the does-not-equal condition in line 40 fails, and the
program concludes at line 50 by printing THAT'S IT.
The foregoing examples all refer to relational opera-
tions as they apply to numeric constants and variables.
They apply equally well to string constants and variables,
however.
The notion of using relational operators to test relation-
ships between strings might seem puzzling at first to
anyone who has very little experience with BASIC. It
might seem curious, for example, to question whether
HELLO is greater-than-or-equal-to GOOD BYE— but it
does make sense.
58
One way to think of relational operations between
strings is in terms of alphabetical sequence. And in that
context, it can be helpful to interpret the relational opera-
tor this way:
A$< B$— the string currently assigned to A$ occurs
alphabetically before the one assigned to B$.
A$> B$— the string currently assigned to A$ occurs
alphabetically after the one assigned to B$.
A$ = B$— the string currently assigned to A$is alpha-
betically identical to the one assigned to B$.
A$< = B$ — the string currently assigned to A$ occurs
alphabetically before, or is identical to, the
one assigned to B$.
A$< = B$ — the string currently assigned to A$ occurs
alphabetically after, or is identical to, the one
assigned to B$.
A$ <> B$ — the string currently assigned to A$is some-
how different from the one assigned to B$.
Here is one of the most popular applications of string
comparisons:
10 DIM K$(1)
20 PRINT "DO YOU WANT TO QUIT (Y/N)";
30 INPUT K$
40 IFK$="Y"THEN END
50 GOTO 20
The basic idea is to determine whether or not the user
wants to end an ongoing program. Line 20 prompts the
user to enter a Y or N response, and line 30 assigns that
string response to variable K$. The conditional statement
in line 40 then tests the user's response against constant Y;
if, indeed, the operator's response is Y, then the program
ends. Otherwise it loops back to line 20 to prompt the user
once again.
59
The next program lets the user enter two different
words, prints them in alphabetical order, and asks
whether or not the user wants to do the whole operation
again.
10 DIMK$(1),X${10),Y$(10)
20 PRINT "ENTER A WORD ";
30 INPUT X$
40 PRINT "ENTER A SECOND WORD ";
50 INPUT Y$
60 IF X$ > =Y$ THEN PRINT Y$:PRINT X$:GOTO 80
70 PRINT X$:PRINTY$
80 PRINT:PRINT "DO AGAIN (Y/N)";
90 INPUT K$
100 IFK$="N"THEN END
110 PRINT:PRINT:GOTO 20
Program lines 20 through 50 prompt the user to enter
two words and, in the process, the statements assign those
words to X$ and Y$. The conditional statement in line 60
compares the two words; and if X$ occurs later alphabeti-
cally, or is identical to Y$, the program prints Y$ followed
by X$. But if the relational condition in line 60 is not satis-
fied, the program executes line 70 to print X$ followed by
Y$.
As mentioned earlier in this discussion, there is some-
thing more to using strings with relational operators than
looking at alphabetical arrangements. BASIC actually
looks at the strings in terms of the ATASCII code number
for each character. (ATASCII is an acronym for ATari
ASCII; and ASCII is an acronym for the standard character-
coding format, American Standard Code for Information
Interchange.) Table 2-3 shows the ATASCII code numbers
for the characters most relevant to this discussion; and a
complete listing appears in Appendix B.
60
Table 2-3
. PartialListingof Characters and ASCII Codes
ASCII
Char
ASCII
Char
ASCII
Char
32
(space)
63
7
93
)
33
!
64
@
94
34
"
65
A
95
—
35
#
66
B
96
V
36
$
67
C
97
a
37
%
68
D
98
b
38
&
69
E
99
c
39
'
70
F
100
d
40
{
71
G
101
e
41
)
72
H
102
f
42
»
73
1
103
g
43
+
74
J
104
h
44
75
K
105
i
45
-
76
L
106
j
46
77
M
107
k
47
/
78
N
108
1
48
79
109
m
49
1
80
P
110
n
50
2
81
Q
111
51
3
82
R
112
P
52
4
83
S
113
q
53
5
84
T
114
r
54
6
85
U
115
s
55
7
86
V
116
t
56
8
87
w
117
u
57
9
88
X
118
V
58
89
Y
119
w
59
90
z
120
X
60
<
91
[
121
y
61
=
92
\
122
z
62
>
NOTE: See Appendix B for a complete listing.
According to that table, the upper-case letter A has a
lower ATASCII code number than does the upper-case Z.
It is the code number that is used when a BASIC^atement
determines whether one letter of the alphabet should
appear before another. That principle leads to the fact
that BASIC will regard all numerals as being "earlier in the
alphabet" than all other letters are. In other words, a
string version of numeral 9 is less than A. By the same
token, all lower-case letters carry larger ATASCII-code
values than the upper-case letters do; thus, a will be
regarded as appearing "later" in the alphabet than Z does.
61
That fact causes some difficulty when you are attempting
to write a program that sorts strings into alphabetical
order when they are composed of combinations of upper-
and lower-case characters. (The way around the difficulty
IS to write a routine that converts all lower-case letters to
their upper-case counterp§rts-by subtracting a value of
32 from all lower-case ATASCII code numbers.)
Logical Operators
Table 2-4 shows the logical operators that are directly
available from ATARI BASIC. There are just three of
them— AND, OR, and NOT— but they are sufficient to
perform any desired logical operation.
Table 2-4. ATARI BASIC'S Logical Operators
Operator
Function
AND
OR
NOT
Logical AND
Logical OR
Logical negation
Used in conjunction with IF . . . THEN conditional
statements, the AND and OR operators connect two or
more expressions in explicit ways. Consider this general
type of AND statement:
IF expr7 AND expr2 THEN expr3
The literal interpretation of that statement is: IFexpr? is
true AND if expr2 is also true, THEN execute expr3. IF
either expr7 or expr2 is not true, then the implication is
that computer operations should ignore the action pre-
scribed by expr3, and go to the next statement in the
program.
By way of a specific example:
IF A > =0 AND A < =9 THEN PRINT A
When executing that statement, the computer will print
the value currently assigned to variable A only if that value
is between and 9, inclusively.
62
A conditional statement that uses AND operators is sat-
isfied only when all of the ANDed expressions are true at
the same time.
Consider this general form of a conditional statement
that uses an OR operator:
IF expri OR expr2 THEN expr3
The literal interpretation of that statement is: \f expri is
true, if expr2 is true, OR if both are true, THEN execute
expr3. IF both expr7 and expr2 are not true, then the
implication is that computer operations should ignore the
action prescribed by expr3, and go to the next statement
in the program.
Here is a specific example:
IF A < OR A > 9 THEN END
When executing that statement, the program will end if
the value currently assigned to variable A is less than or if
it is greater than 9.
A conditional statement that uses OR operators is satis-
fied when one or more of its ORed expressions are true.
The AND and OR operators are both binary logical
operators in the sense that they connect at least two dif-
ferent expressions. The NOT operator, on the other hand,
is an unary operator — it applies to a single expression.
The NOT operator reverses the logic of the expression
to which it applies. For instance:
IFNOTA> 10THEN END
That statement literally says: IF the value currently assigned
to variable A is NOT greater than 10, then END the
program.
The foregoing examples each used one particular logi-
cal operator; but it is often necessary to use various com-
binations of them within the same conditional statement.
63
Order of Precedence for Operators
Many programming situations call for including more
than one operator within a statement— combinations of
more than one arithmetic, relational, and logical operator.
That situation gives rise to a question concerning the
order of precedence. Will the operators be regarded by
the computer in a strict left-to-right sequence, or will
some operators take a priority of execution over others?
The answer to that question is, "Yes."
Table 2-5 shows the order of precedence for the execu-
tion of BASIC'S operators. Those having a higher order of
precedence will always be executed before others having
a lower order. And operators having the same order of the
precedence will be executed in a left-to-right sequence.
Table 2-5. Order of Precedence of
ATARI BASIC Operators
Operator
Function
Precedence Level
Grouping
()
Sign of grouping
9 Highest precedence
Arithmetic Operators
-
Exponentiation
8
-
Negation
7
Multiplication
6
/
Division
6
+
Addition
5
—
Subtraction
5
Relational Operators
=
Equal
4
<
Less than
4
>
Greater than
4
< =
Less than or equal to
4
> =
Greater than or equal to
4
<>
Not equal
4
Logical Operators
NOT
Logical negation
3
AND
Logical AND
2
OR
Logical OR
1 Lowest precedence
64
Suppose that you have written a BASIC statement of this
form:
A=B+2-C/16*D
Of all the operators appearing in that statement, the
multiplication operator has the highest priority. The signif-
icance of that fact is that the computer will do the 16*D
operation before any others. It will then deal with the
division operator; having already multiplied constant 16
by variable D, the computer divides that result into varia-
ble C. What remains, then, are the addition and subtrac-
tion operations.
According to the established order of precedence, addi-
tion and subtraction operators have the same order of
precedence; and in such instances, the computer exe-
cutes the operators from left to right. In this particular
example, that means summing variable B with constant 2,
and then subtracting the result of the previously executed
C/16*D operators from the result.
The same idea applies to all of the operators cited in the
table. Notice that all of the relational operators have the
same level of precedence. That means they will be
regarded in a strict left-to-right sequence. The logical
operators are at the bottom of the list, thereby taking the
lowest levels of precedence.
Perhaps it seems that a need for setting up BASIC state-
ments according to those fixed orders of precedence
makes it troublesome for a programmer. That isn't quite
the case, however. BASIC includes signs of grouping, par-
entheses, that take precedence over all other operators.
And that means it is possible to specify the operators in
any convenient or meaningful sequence and then use sets
of parentheses to establish the order of execution.
Recall this BASIC statement:
A=B+2-C/16*D
65
It is possible to avoid any troublesome references to the
orders of execution by expressing it this way;
A=B+2-{C/(16*D))
Knowing that nested parenthetical expressions are always
executed from tlie Innermost to outermost levels, that
form of the statement more clearly suggests: multiply 16
times D, divide the result into C, subtract the result from 2
and add variable B. Having to recall the orders of prece-
dence is far less important when using parentheses to dic-
tate the sequence.
66
chapter 3
The BASIC
Programming Language
This chapter summarizes the ATARI BASIC programming
language. Many of the examples apply equally well to
other versions of BASIC as run on other kinds of personal
computers. But for the most part, the examples and dis-
cussions assume that you are working with the ATARI
BASIC cartridge.
The purpose of the chapter is to provide a ready refer-
ence for the BASIC commands, statements, and functions.
There are some differences between ATARI BASIC and
some other commonly used versions; and readers who
have previously learned BASIC from other sources will
find this material a handy guide for dealing with those
differences.
It is beyond the scope of this book to deal with the
general principles of BASIC programming on an elemen-
tary level, however; so anyone who is not already
acquainted with the essential elements of programming in
BASIC should refer to an appropriate beginner's book.
67
A SUMMARY OF STATEMENTS. COMMANDS. AND
FUNCTIONS
Chart 3-1 is an alphabetical listing of the primitive com-
mands, statements, and functions for ATARI BASIC. Most
of them will be familiar to readers who have learned
BASIC before, and they can be found in most other books
that deal with BASIC in a general fashion.
Table 3-1 classifies the instructions according to their
general use and, incidentally, cites some abbreviated
forms that can simplify the keyboard-programming task.
Generally, the BASIC Commands are executed directly
from the keyboard while the computer is in its program,
or immediate, mode of operation. Most of them, how-
ever, can be included within a program and, in fact, are
truly useful only in that context.
The Control Statements control the flow of an operating
BASIC program. As shown in the table, many of them
represent two-word statements.
The Input/Output Commands generally control the
flow of information— into the computer, out of the com-
puter, and between different sections within the com-
puter.
There are relatively few ATARI BASIC commands that
are specifically designed for string operations; but the
String Commands and Functions can be used with other
statements to yield a wide range of useful string
manipulations.
The Math Functions are common to most versions of
BASIC and they can be organized to execute virtually any
mathematical calculation. A table of Derived Trigonomet-
ric Functions appears in Appendix F.
There are only two Array Statements; however, it is
quite possible to compound other kinds of statements to
manipulate any sort of array or matrix.
68
Chart 3-1 . Alphabetical Listing of ATARI BASIC
Primitive Commands. Statements, and Functions
ABS
ADR
ASC
ATN
BYE
CLOAD
CHR$
CLOG
CLOSE
CLR
COLOR
COM
CONT
COS
CSAVE
DATA
DEG
DIM
DOS
DRAWTO
END
ENTER
EXP
FOR
FRE
GET
GOSUB
GOTO
GRAPHICS
IF
INPUT
INT
LEN
LET
LIST
LOAD
LOCATE
LOG
LPRINT
NEW
NEXT
NOTE
ON
OPEN
PADDLE
PEEK
PLOT
POINT
POKE
POP
POSITION
PRINT
PTRIG
PUT
RAD
READ
REM
RESTORE
RETURN
RND
RUN
SAVE
SETCOLOR
SGN
SIN
SOUND
SQR
STATUS
STEP
STICK
STRIG
STOP
STR$
THEN
TO
TRAP
USR
VAL
XIO
69
Table 3-1. ATARI BASIC Commands, Statements,
and Functions
Arranged by Their General Purposes
ATARI BASIC Commands
Command
Abbreviation
BYE
B.
CONT
CON.
END
none
LET
LE.
LIST
L.
NEW
none
REM
R. or period followed by a space
RUN
RU.
STOP
STO.
ATARI BASIC Control Statements |
Command
Abbreviation
FOR
F.
GOSUB
GOS.
GOTO
G.
IF
none
NEXT
N.
ON
none
POP
none
RESTORE
RES.
RETURN
RET.
STEP
none
THEN
none
TO
none
TRAP
T.
NOTE: Some of these statements must be used In conjunction with
others in order to complete their meaning:
FOR . . . TO . . . NEXT
GOSUB . . . RETURN
ON . . . GOSUB
FOR . . . TO . . . STEP . . . NEXT
IF. . THEN
ON . . . GOTO
70
Table 3-1— cont. ATARI BASIC Commands,
Statements, and Functions
Arranged by Their General Purposes
Input/Output Commands
Command
Abbreviation
CLOAD
CLOA.
CLOSE
CL
CSAVE
CS.
DATA
D.
DOS
DO.
ENTER
E.
GET
GE.
INPUT
1.
LOAD
LO.
LPRINT
LP.
NOTE
NO.
OPEN
0.
POINT
PO.
PRINT
PR. or ?
PUT
PU.
READ
REA.
SAVE
S.
STATUS
ST.
XIO
X.
NOTE: Some of these statements must be used in conjunction with
another in order to make up complete I/O operations:
OPEN . . . CLOSE
READ . . . DATA
OPEN . . . END
ATARI BASIC String Commands
and Functions
Command
Abbreviation
ASC
none
CHR$
none
LEN
none
STR$
none
VAL
none
71
Table 3-1— cont. ATARI BASIC Commands,
Statements, and Functions
Arranged by Their General Purposes
ATARI BASIC Math Functions
Function
Abbreviation
ABS
none
ADR
none
ATN
none
CLOG
none
COS
none
DEC
none
EXP
none
PRE
none
INT
none
LOG
none
PEEK
none
POKE
none
RAD
none
RND
none
SGN
none
SIN
none
SQR
none
USR
none
ATARI BASIC Array Statements
Statement
Abbreviation
DIM
Dl.
CLR
none
ATARI BASIC Graphics Commands
Command
Abbreviation
GRAPHICS
GR.
COLOR
C.
DRAWTO
DR.
GET
GE.
LOCATE
LOC.
PLOT
PL.
POSITION
POS.
PUT
PU.
SETCOLOR
SE.
XIO
X.
72
Table 3-1— cont. ATARI BASIC Commands,
Statements, and Functions
Arranged by Their General Purposes
ATARI BASIC Sound
and Game-Controller Commands
Command
Abbreviation
SOUND
PADDLE
PTRIG
STICK
SO.
none
none
none
The Graphics Commands refers to what is now com-
monly regarded as the most powerful feature of the
ATARI system — its graphics.
The Sound and Game-Controller Commands might be
better classified among the I/O commands; but they are
set apart here in order to underscore their existence as a
special kind of command.
A SUMMARY OF ATARI BASIC SYNTAX
AND APPLICATIONS
This section describes, in alphabetical order, all ATARI
BASIC commands, statements and functions. The purpose
is to show the proper syntax and suggest some applica-
tions. Most of the descriptions are complete in their own
right, but others refer you to further details in other
chapters.
ABS(x)
ABS(x) is a numeric function that returns the absolute, or
unsigned, value of x, where x is any numeric constant or
expression.
Examples:
PRINT ABS(-1 .2),ABS(30)
The example will print 1.2 and 30 — the unsigned values
of -1.2 and 30.
73
10 FOR N = -5 TO 5
20 PRINT N,ABS(N)
30 NEXT N
That program will return this sort of display:
-5 5
-4 4
-3 3
-2 2
-1 1
1 1
2 2
3 3
4 4
5 5
ADR(x$)
ADR{x$) is a special control function that returns the RAM
address of the first character in string x$; where x$ is a
string variable or constant.
Whenever a program dimensions a string variable
ATARI BASIC sets aside the specified amount of RAM
space This control function allows you to locate the start-
ing address of that string. The function is especially useful
or passing string variables to USR-called machine-
language routines (see Chapter 7).
Demonstration Program:
10 DIM M$(5)
20 M$="HELLO"
30 SA=ADR{M$)
40 FOR 1=0 TO LEN(M$)-1
50 PRINT SA+I,CHR${PEEK(SA+I))
60 NEXT I
74
Lines 10 and 20 simply dimension string variable M$ and
assign string HELLO to it. Line 30 uses the ADR function to
determine the starting address of the string and assigns
that value to SA. The remaining lines then increment the
address locations, PEEKing into each one and printing the
addresses and character contained in each one of them.
AND
AND is used as a logical operator in conditional state-
ments such as:
IF expr1 AND expr2 THEN statement
The statement is executed only if both expri AND expr2
are true.
Examples:
IF X > =0 AND X < =9 THEN PRINT X
The statement will print the current value of X only if that
value is both greater than or equal to AND less than or
equal to 9. If X happens to be less than or greater than 9,
the PRINT statement is not executed.
IF K$="Y" AND V < 1 THEN END
That line will END its program only if string K$ is Y AND
the value currently assigned to V is less than 10.
See Chapter 2 for further details.
ASC(x$
ASC(x$) is a string function that returns the ATASCII code
number for the first character in string x$; where x$ is a
string variable or constant. If x$ is the null character, the
function returns an ATASCII value of 44.
Examples:
10 DIM M$(1)
20 M$="Y"
30 PRINT ASC(M$)
75
That routine will print 89 to the screen— the ATASCil
code for upper-case Y.
10 DIMM$(5)
20 M$="HELLO"
30 PRINT ASC(M$)
In this instance, the computer will print 72 to the screen—
the ATASCil code for the first character in HELLO.
On occasions where it is necessary to print the ATASCil
codes for all of the characters in a specified string variable,
use this sort of routine:
10 DIMM$(5)
20 M$="HELLO"
30 FOR C=0TO LEN{M$)-1
40 PRINT PEEK{ADR(M$)+C)
50 NEXTC
ATN(x)
ATN(x) is a numeric function that returns the Arctangent,
or inverse tangent, of x; where x is any floating-point con-
stant or expression.
The Arctangent value of a number is the angle whose
tangent is equal to that number. BASIC will normally
express the angle in units of radian measure, but preced-
ing the operation with a DEC command will cause all
angles to be expressed in degrees.
BYE
Abbreviation: B.
BYE is a command that switches from ATARI BASIC to the
Memo Pad screen mode. The command does not affect
resident BASIC programming, current variable assign-
ments, DOS or RS-232 assignments. Return to BASIC from
the Memo Pad by striking the SYSTEM RESET key.
76
CLOAD
Abbreviation: CLOA.
CLOAD is a command that loads tokenized BASIC into the
computer from the program recorder. Upon executing
the command, the computer will generate a brief audio
signal. Respond to that signal by locating the beginning of
the program to be loaded, depressing the PLAY switch on
the recorder and striking any key on the console (except
the BREAK key). The loading is done when the READY
message is printed again to the screen.
CLOAD works only with cassette-based programs that
have been recorded with the tokenizing CSAVE or SAVE
statements. It does not work with ATASCII-formatted files
that have been saved by means of the LIST command. See
Chapter 6 for further information.
CLOAD operations automatically refer to the device to
lOCB Channel 7, so it must be closed if it has been opened
for any other purpose.
CHR$(x)
CHR$(x) returns the string value that is represented by
ATASCII codex; wherex is a numeric constant or expres-
sion that has a value between and 255.
Examples:
10 FORC=97to122
20 PRINT C,CHR$(C)
30 NEXTC
The routine prints the ATASCII codes and characters for
all lower-case letters of the alphabet.
10 FORC=97to122
20 CHR$(C),CHR$<C-32)
30 NEXTC
77
This example increments through the ATASCII codes for
the lower-case letters of the alphabet. Line 20 first prints
the lower-case character and then subtracts 32 from the
current ATASCII value to specify and print the upper-case
version.
CLOG(x)
CLOG(x) is a numeric function that returns the base-10
logarithm of x; where x is a floating-point constant or
numeric expression that is greater than zero.
Use the LOG(x) function when it is desirable to obtain
the natural, base-e logarithm of x.
CLOSE #x
Abbreviation: CL.
CLOSE is a statement that closes the lOCB channel that is
specified by x; where x is a valid channel number— an
integer value between and 7.
Executing an END statement closes all lOCB channels
except 0, which is normally assigned to the screen editor.
See Chapter 6 for further details concerning lOCB
operations.
CLR
CLR is a command that sets all numeric variables and DIM
assignments to zero, and resets the DATA-list pointer.
An inappropriate application of CLR can destroy vital
information; but a proper application makes it possible to
zero numeric arrays very efficiently, redimension string
variables, and re-READ a DATA list from the beginning.
78
COLOR X
Abbreviation: C.
COLOR is a graphics function that determines the color
register for subsequent PLOT and DRAW TO statements;
where x is a positive numeric value or expression.
The relationship between the COLOR value and the
color of the text or graphic printed on the screen depends
largely upon the current graphics mode. See more details
in Chapter 4.
COM x$(x),y${y) . . .
COM Xliy1,zl), x2(y2,z2) . . .
The COM statement defines the length of string variables
and the size of numeric arrays. Its application is virtually
identical to the more commonly used DIM statement.
Example:
COM SA(4,5),M$(5)
That command dimensions numeric variable SA for a 4 by
5 array and sets the length of string variable M$to 5. It is
funrtionally identical to:
DIM SA(4,5),M$(5)
CONT
Abbreviation: CON.
CONT is a command that can, under the proper circum-
stances, allow a program to CONTinue after it has been
halted. Normally it is used in conjunction with the STOP
command as a program-debugging tool— whenever pro-
gram execution is halted by a STOP command, you can
resume operations from the beginning of the following
program line by entering the CONT command.
79
CONT can also be used in conjunction with a BREAK-
key depression to stop and then resume the LISTing of a
program on the video screen. Once a LIST is initiated, it
can be stopped for inspection by striking the BREAK key;
and then the listing can be resumed by entering the
CONT command.
The CONT command does not yield reliable results
when It is used after other kinds of program-halting events
have occurred.
COS(x)
COS(x) is a numeric function that returns the trigonomet-
ric cosine of an angle expressed as x; where x is a floating-
point constant or numeric expression. The expression, x, is
normally taken as an angle that is expressed in radians, but
It can be expressed in degrees by preceding the functions
with a DEC command.
CSAVE
Abbreviation: CS.
CSAVE is a command that is used for saving tokenized
BASIC programs on the program recorder. Upon execut-
ing the command, the computer will respond with two
beeping signals. Begin the recording by depressing the
PLAY and RECORD buttons on the program recorder and
striking any key on the console, except the BREAK key
The system signals the end of the saving operation by
reprinting the READY message.
CSAVE automatically opens lOCB Channel 7, so it is
important that the channel be closed prior to executing
the CSAVE command.
Because CSAVE saves BASIC programs in a tokenized
format, they can be reloaded only by means of the
CLOAD command. See Chapters 7 and 8 for further details
about tokenized BASIC.
80
DATA list
Abbreviation: D.
DATA is a nonexecutable statement that contains the list
of items to be read by a READ command. The items in the
list can be numeric constants or string constants separated
by commas. String constants in a DATA list need not be
enclosed in quotation marks.
Numerical and string constants can be mixed within the
same DATA list, but only as long as the corresponding
READ operation specifies the correct variable type.
Examples:
10 F0RN=1 TO 5
20 READ A: PRINT A
30 NEXT N
40 DATA 100,200,300,400,500
That routine will read and print the numeric constants,
one at a time, from the DATA list.
10 DIMA$(10)
20 FOR N=1 TO 5
30 READ A$:PRINTA$
40 NEXT N
50 DATA, HARRY,GEORGE,RALPH,CINDY,JUDY
The routine reads and prints the five string constants spec-
ified in the DATA list.
10 DIM N$(10)
20 FOR N=1 TO 4
30 READ N$,A:PRINT N$,A
40 NEXT N
50 DATA SUSAN, 20,JENNIFER,18,MIKE,22,TED,21
Line 30 reads a string value followed by a numeric value,
and then prints them to the screen in that sequence.
Notice that the DATA listing includes variable types in that
same sequence — a string followed by a numeric value.
81
See the READ and RESTORE statements for further
examples and relevant details.
DEC
Abbreviation: DE.
DEC is a command that converts all subsequent angular
expressions to units of degrees. Use the RAD command to
reset the normal units of radians.
DIMx$(x),y$(y) ...
DIM Xl(y1,z0,x2(y2,z2) ...
Abbreviation: Dl.
The DIM statement defines the length of string variables
and the size of numeric arrays. It must be executed in the
program prior to making any reference to the variables.
Examples:
DIM M$(20)
That statement dimensions string variable M$ for up to 20
characters.
DIM X(4)
That statement dimensions five subscripted variables of
X— variables X(0) through X(4).
DIM M${10),X(2,4)
That statement dimensions string M$for up to 10 charac-
ters, and defines a 2 by 4 array for variable X.
See Chapter 2 for further details about dimensioning
string variables, subscripted numeric variables, and
numeric variable arrays.
DOS
DOS is a command that brings up the utility menu for the
Disk Operating System (see Chapter 1). Return to BASIC
by selecting menu-item B or striking the SYSTEM RESET
key.
82
DRAWTO x,y
Abbreviation: DR.
DRAWTO draws a straight line from the last-plotted graph-
ics point to a point having coordinates x and y; where x
and y are numeric constants or expressions that evaluate
to valid points for the current graphics mode.
See further details in Chapter 4.
END
END is a statement that is sometimes necessary for signal-
ing the final statement in a BASIC program. The statement
is not necessary if the last statement to be executed in the
program happens to carry the highest-valued line number.
END closes all lOCB channels except No. 0, which is
normally assigned to the screen editor.
ENTER device
Abbreviation: E.
ENTER is a command that is used for merging ATASCII-
coded BASIC programming from device (cassette or disk)
to the computer's memory. Existing programming is not
erased; rather, the new program lines are added to (or
merged with) the existing ones. In instances where the
new programming has line numbers that are identical to
those already in program RAM, the new numbers and
statements write over the old ones.
In a similar way, ENTER can add new variable specifica-
tions to the existing program, and it will not affect existing
specifications unless they are redefined by the incoming
program.
ENTER automatically opens lOCB Channel 7 for loading
the new programming, and it closes that channel when
the transfer is completed.
Because ENTER works only with ATASCII-coded pro-
gramming, it loads only tokenized BASIC programs that
were saved by means of the LIST command.
83
Examples:
ENTER "C:"
That command loads, or merges, untokenized files from
the program recorder.
ENTER "D:NEWSTF.ASC"
That command merges an ATASCII-coded program named
NEWSTF.ASC from the default disk.
See Chapter 6 for further details regarding the nature of
tokenized programs and nontokenized files.
EXP(x)
EXP(x) is a numeric function that returns constant e
(2.71828182) to a power of x; where x is a floating-point
numeric constant or expression.
FOR var = begin TO end [STEP y]
Abbreviations: pqr p
NEXT N.
This statement defines and initiates a FOR . . . NEXT
loop. A numeric variable name, var, is stepped between
values begin and end; where begin and end are numeric
constants or expressions. Unless specified otherwise by
the STEP option, the FOR . . . NEXT loop increments var
in steps of +1. Other STEP intervals are determined by the
numeric constant or expression, y.
FOR must be used with a corresponding NEXT state-
ment.
Examples:
10 FOR N=0TO 9
20 PRINT "HELLO"
30 NEXTN
That example prints HELLO 10 consecutive times on the
screen.
84
10 FORX=0TO 100 STEP 2
20 PRINT X
30 NEXTX
That example prints even-valued integers between and
100.
10 FORDWN=10TO-10STEP-1
20 PRINT OWN
30 NEXT DWN
That routine prints backwards from 10 to -10, and prints
each of the integers in that range.
10 FOR N=0TO9
20 PRINT N;
30 FORT=0TO 100
40 NEXTT
50 NEXT N
The example uses an outer loop to establish and print
values of N and a second, inner loop to execute a time
delay between each printing. The example, in other
words, uses nested FOR . . . NEXT loops. Notice that the
FOR statements refer first to variable N and then T, while
the NEXT statements refer to variable and then N.
There are a couple of techniques for breaking out of a
FOR . . . NEXT loop before var reaches the end value.
One way is to assign a value to var that is equal to end
within the loop, itself. Basically, the following program
counts and prints integer values from zero to whatever
value is assigned to variable N, but never more than 9. So if
you respond to the prompting message by entering a 4,
the program will print integers through 4; if you enter 9,
it will print through 9; but if you enter any number
larger than 9— even 1000000— line 50 forces the FOR . . .
NEXT loop to a premature conclusion.
85
10 PRINT "ENTER A POSITIVE NUMBER:";
20 INPUT N
30 FORK=0TON
40 PRINT K
50IFK>=9THENK=N
60 NEXT K
A second way to terminate a FOR . . . NEXT loop is to
use statements POP:GOTO line number. The following
example runs just like the previous one, but uses the POP
statement to force the computer to "forget" it is running a
FOR . . . NEXT loop. A NEXT-Without-FOR error will
occur if you fail to follow the POP statement with a well-
defined GOTO statement.
10 PRINT "ENTER A POSITIVE NUMBER:";
20 INPUT N
30 FOR K=0TO N
40 PRINT K
50 IF K > =9 THEN POP:GOTO 70
60 NEXTK
70 END
FRE(x)
FRE(x) is a numeric function that returns the number of
bytes of RAM that remain available for the user's pur-
poses. Variable x is a "dummy variable," so its value is not
relevant as long as it is a valid floating-point constant or
numeric expression.
Example:
PRINT FRE(O)
That will print to the screen the amount of RAM that
remains available for the program.
86
GET #x, var
Abbreviation: GE.
GET fetches a single byte from opened lOCB Channel x,
and subsequently assigns the value to var. The type
(numeric or string) of the fetched item must match that of
var.
Example:
10 OPEN #1,4,0, "K:"
20 GET#1,K$
30 IF K$ < ="A" AND K$ < ="Z" THEN PRINT K$;
:GOTO 20
Line 10 opens iOCB Channel 1 for input from the console
keyboard. Line 20, in effect, waits for a single keystroke;
and when it occurs, it assigns the character string to varia-
ble K$. If, according to line 30, the character is an upper-
case letter of the alphabet, the program prints the charac-
ter and loops back to line 20 to fetch the next keystroke. A
keystroke representing anything but an upper-case letter
will bring the program to an end (and close IOCB Channel
1). That particular example can be quite useful for fetching
single-keystroke characters without having to conclude
the entry by striking the ■aaiiia^^^ key (as is the case with
INPUT statements).
GOSUB line number
Abbreviation: GOS.
GOSUB line number is a program-control statement that
directs the execution of a program to a subroutine that
begins a line number. Unless the subroutine ends the
entire program with an END statement, it must conclude
with a RETURN statement that will return program opera-
tions to the statement that follows GOSUB.
87
Because GOSUB refers to a specific line number, line
number must be a positive integer constant or numeric
expression that refers to a line number in the existing
program.
A conditional POP statement that is included within a
subroutine makes it possible to nullify the normal,
automatic-return feature of a RETURN statement. You
can, for instance, execute a GOSUB statement, run a por-
tion of the routine and, if desired, break completely away
from the subroutine. Suppose that this sort of conditional
statement appears at line 1020 in a subroutine:
1 020 IF X > 5 THEN POP:GOTO 1 00
If variable X happens to take on a value that is greater than
5, the computer will "forget" that it was executing a sub-
routine, and go immediately to line 100. Some sources
regard this optional POP feature as a technique for
dynamically transforming a GOSUB operation into a
GOTO operation.
GOTO line number
Abbreviation: G.
GOTO line number is a program-control statement that
directs the execution of a program directly to line number.
Because line number represents a specific line number in
the program, it must be a positive integer constant or
numeric expression.
Examples:
10 GOTO 100
That will direct the program to line 100.
10 GOTO 10*N
That will direct the program to a line number that is equal
to 10 times the numeric value currently assigned to varia-
ble N. The expression, of course, must point to a line
number that exists in the program at the time.
88
GRAPHICS X
Abbreviation: GR.
The GRAPHICS command sets the ATARI BASIC graphics
mode, where x is a numeric constant or expression that
represents a valid graphics-mode number.
If X is a positive integer value between and 8, the
command will set the normal graphics modes, clear the
screen and establish the normal text windows.
Adding a constant 16 to the value sets the graphics
modes through 8, clears the screen, but does not include
the normal split-screen text windows.
Adding a constant 32 to the value retains the split-
screen text windows, but prevents the mode operation
from clearing the screen.
Adding a constant 40 suppresses the text windows and
the screen-clearing operations.
See Chapter 4 for further examples and details.
IF expr THEN statementxtatement . . .
IF . . . THEN is BASIC'S primary conditional statement.
Literally it says: IF some arithmetic or logical expression,
expr is true, THEN execute the specified statement or
sequence of statements. By implication, if the statement is
NOT true, then ignore any following statements, and
GOTO the beginning of the next program line.
Example:
IF K$="Y" THEN PRINT "DONE ":END
That statement literally says: IF the string currently
assigned to variable K$ is a Y, then print DONE and END
the program (otherwise, go to the next line of pro-
gramming).
If the statement portion of an IF . . . THEN statement
happens to be a GOTO line number statement, you can
shorten the programming a bit:
89
IF A < =10 THEN GOTO 100
is the same as
IFA<=10THEN 100
A line number following the THEN portion of an IF . . .
THEN statement implies a GOTO operation.
INPUT varl, var2. . . .
INPUT #cfiafi,var,var...
Abbreviation: I.
The simplest form of the INPUT statement halts the execu-
tion of a program, prints a question mark on the screen,
andaw^s a response from the keyboard that ends with a
■ in i 'l i lW keystroke. The statement assigns the keyboard
entry to the var.
Examples:
INPUT X
The program in that instance is expecting a numeric value
from the keyboard and will subsequently assign it to vari-
able X.
INPUT X:N(1)=X
INPUT statements cannot directly assign values to sub-
scripted numeric values. The example shows how the
INPUT value is first assigned to variable X, and then an
assignment statement assigns X to subscripted variable
N(1).
INPUT M$
The program in that instance is expecting a string entry
from the keyboard, and it will subsequently assign it to
string variable M$. The variable, of course, must be prop-
erly dimensioned at some earlier point in the program.
It is possible to enter more than one numeric or string
constant from the keyboard under a single INPUT state-
ment. Such compound INPUT statements must show the
variable names separated by commas.
90
Examples:
INPUT X,Y,Z
The INPUT statement is expecting three consecutive
numerical constants from the keyboard. The operator has
the option of entering all three constants, and separating
them with commas before striking the ■^■■■■a^^" key; or
striking the ■"■■""^^* key after each entry.
INPUT A$,B$,C$
That INPUT statement expects a series of three string-
constant entries from the keyboard. Each string entry must
conclude with a ■"*"'"^^* keystroke.
INPUT X,A$
The example shows that it is possible to mix variable types
within a compound INPUT statement. This one is expect-
ing a numeric constant followed by a string constant.
Unless specified otherwise, it is assumed that the INPUT
statement is expecting numeric or string constants from
the keyboard — actually, the screen editor assigned to
iOCB 0. It is altogether possible, however, to assign the
INPUT statement to other input sources.
The general form of the INPUT statement in that case is:
\NP\JJ Uchan,var
where chan is the lOCP channel number that is to supply
the constant for variable var.
The simple INPUT statement cited earlier will always
print a prompting question mark. That feature is usually an
asset, but it is often inappropriate. The following example
allows the operator to enter a numeric constant from the
keyboard by first assigning the keyboard to IOCB 1. The
question mark will not appear in that instance. (Unfortu-
nately, the entry isn't printed to the screen while it is
being entered, either.)
91
10 OPEN #1,4,0, "K:"
20 PRINT "ENTER A NUMBER BETWEEN AND 9 "
30 INPUT #1,X
40 CLOSE #1
See Chapter 6 for additional information regarding the
INPUT statement as a dynamic I/O command.
INT(x)
INT(x) is a numeric function that returns the next-smaller
integer value of x; where x is any floating-point constant
or expression.
Examples:
PRINT INT(3.8)
That statement will print 3 to the screen.
PRINT INT(8.3)
That will print 8 to the screen.
PRINTINT(-1.2)
Bearing in mind that negative values that are farther from
zero are considered to be smaller than those closer to
zero, that statement will print -2 to the screen.
LEN(x$)
LEN (x$) is a string function that returns the number of
characters assigned to string x$.
LET var=expr
Abbreviation: LE.
LET is a variable-assignment statement that assigns a
numeric or string constant or expression, expr, to a desig-
nated numeric or string variable name, var.
The variable types must match: numeric values and
expressions must be assigned to numeric variable names,
and string values and expressions must be assigned to
string variable names.
92
The LET expression is actually optional; var = expr is
adequate.
Examples:
LETX=1+Y
LET X$="FLIP YOUR WIG"
G=X*Y
LIST output device start line, last line
Abbreviation: L.
The LIST command is used for writing information, or
selected portions of it, to the designated output device in
an ATASCil-coded format. If no output device is desig-
nated in the command, the system automatically assumes
it to be the video display. The terms first line and last line
represent program line numbers that may be used in the
following combinations:
LIST — list the entire program, from the lowest-numbered
line through the highest-numbered line.
LIST start line — list only line number start line in the
program.
LIST start line, last line — list the program, beginning from
line number start line and ending with line number last
line.
Values start line and last line need not refer to specific
line numbers in the program, but they must be positive
integer values.
Examples:
LIST 1
That command lists program line 10 to the screen.
LIST"P:"
That command lists the entire program to the ATARI
printer.
93
LIST "D:TRY.BAS"
That command saves the entire BASIC program as TRY.
BAS in ATASCII-coded (nontokenized) format to the
default disk drive. See Chapter 6 for further details con-
cerning ATASCII-coded programs and files.
A LISTing operation can be aborted by striking the
BREAK or SYSTEM RESET keys, but the user should be
aware that such an interruption will render LISTs to the
program recorder or disk system useless.
LOAD input device
Abbreviation: LO.
LOAD is used for loading BASIC programs or files into the
system from the designated input device. The specified
device must be one that is appropriate for input opera-
tions and the programming must have been saved in a
tokenized format— by means of a SAVE command. Be-
cause programs that are saved by CSAVE or LIST com-
mands are saved in an ATASCII-coded format, they cannot
be loaded by means of the LOAD command.
See Chapter 1 for applications of the LOAD command
and Chapters 6 and 7 for further information about token-
ized BASIC.
LOCATE col,row^
Abbreviation: LOC.
LOCATE is a graphics function that determines the charac-
ter or graphics code for a specified screen position, and
assigns the value to a numerical variable, x. The screen
position is given in column/row coordinates, col and row,
that are appropriate for the current graphics mode.
In graphics Modes 0, LOCATE returns the ATASCII code
number for the character at col,row.
In graphics Modes 1 and 2, LOCATE returns a value that
indicates both the character being displayed and the color
register it is using.
94
In graphics Modes 3 through 8, LOCATE returns the
color register being used for plotting to co/,row.
See Chapter 4 for further details concerning the format-
ting of text and graphics data.
The LOCATE statement is not valid until the program
executes a GRAPHICS statement, thereby opening lOCB
Channel #6 for input from the screen.
Executing the LOCATE statement automatically leaves
the print cursor (whether it is actually visible or not) at the
column location that immediately follows the col,row
designation.
LOG(x)
LOG(x) is a numeric function that returns the natural,
base-e, logarithm of x; where x Is a floating-point constant
or numeric expression that is greater than zero.
Use the CLOG(x) function when it is desirable to obtain
the base-10 logarithm of x.
LPRINT expr list
Abbreviation: LP.
LPRINT is a statement that is quite similar to PRINT, but
prints data to an ATARI printer instead of the video
screen. It can print lists, numeric constants and expres-
sions, as well as string constants and expressions.
If the items in the expr list are separated by a semicolon,
the printing of one item begins immediately after the end
of a previous one. If the items are separated by a comma,
each is printed at the beginning of the next-available tab-
stop column on the screen.
LPRINT uses lOCB Channel #7.
NEW
NEW is a command that, in effect, clears all existing BASIC
programming from RAM. It also closes all lOCB channels
except #0 (which is used for the screen editor), and sets all
trigonometric functions to work in units of radians.
95
It is advisable to execute the NEW command prior to
entering a new program.
NEXT
Abbreviation: N.
The NEXT statement is meaningless without a preceding
FOR statement. See FOR.
NOT
NOT is a logical operator that is used to negate a logical
expression. It is generally used in conditional statements
such as:
IF NOT expression THEN statement
See Chapter 2 for further details.
NOTE itchan,sec,byte
Abbreviation: NO.
The NOTE function returns the sector and byte values at
the current disk-file pointer position for a disk device at
lOCB channel, chan. Those values are assigned to the
designated numeric variable, sec and byte.
The NOTE function is not available under ATARI DOS
1.0.
ON X GOSUB Iine1jine2 . . .
ON . . . GOSUB is a control statement that calls a subrou-
tine beginning at one of a list of line numbers, linel,
Iine2, . . . and so on. The line number that is selected is
determined by the current value of the integer expres-
sion, X. If X happens to have a value of 1, the statement will
call the subroutine specified by the first line designation;
if X is equal to 2, the statement will call the second-
specified line; if x is equal to 8, the statement will call a
subroutine that begins at the eighth line number in the
list.
96
If it happens that the current value of x is or if its value
exceeds the number of lines designated in the program,
the computer ignores the ON . . . GOSUB altogether and
goes to the next statement.
Examples:
10 F0RN=1 TO 5
20 ON N GOSUB 1 00, 1 1 0, 1 35, 1 00, 1 50
30 NEXT N
As the value of N increments from 1 through 5, line 20 calls
subroutines that begin at lines 100, 110, 135, 100 and 150 in
that order. (Notice that it is possible to call the same sub-
routine more than one time within the list.)
100 0NX=GOSUB 1000, X* 100, 200
If X is equal to 0, the computer will ignore this statement
and resume execution from the next-available program
statement. If X is equal to 1, the statement will send opera-
tions to a subroutine beginning at line 1000; and when X is
equal to 2, the computer will consider the X*100 listing
and send the operations to line 200. When X is equal to 3,
the program will look at the third line listing, and send
operations to a subroutine that begins at line 200. Finally,
whenever X is greater than 3, the computer will resume
execution from the next-available program statement.
ON X GOTO I'me1,line2 . . .
ON . . . GOTO is a control statement that selects one of
any number of line numbers that are listed in the state-
ment. The general features and purposes are nearly iden-
tical to those for the ON . . . GOSUB statement. The only
differences are those that distinguish the simpler GOTO
and GOSUB statements.
OPEN #c/ian,fask,aux,"dev"
Abbreviation: O.
97
The OPEN command represents the most direct and use-
ful means for opening an iOCB channel for service. Some
ATARI BASIC functions automatically open certain chan-
nels, but a good many operations call for opening and
configuring a channel for a particular purpose.
The command has four different arguments. The first,
chart, designates the channel that is to be opened— 1
through 7; and the last, dev, designates the type of device
the channel is to service. Parameters task and aux define
the operations.
Chapter 6 includes tables for defining those arguments
for given devices.
Examples:
0PEN#1,4,0,"K:"
That opens IOCS Channel #1 for input from the keyboard.
The function is especially useful, when in conjunction
with a subsequent INPUT #1,X statement, for picking up
single-keystroke character codes from the keyboard.
OPEN #2,1 3,0,"R1;"
That opens IOCB Channel #1 for read/write operations
from RS-232 serial port number 1. The device handler rou-
tine, AUTORUN.SYS, must be resident in the system
before any serial operation can be performed.
All channels thus opened will be automatically closed
when the program reaches its end. You can close all chan-
nels during the execution of a program (except #0 for the
screen editor) by executing a CLOSE command.
OR
OR is used as a logical operator in conditional statements
such as:
IF expr7 OR expr2 THEN statement
See Chapter 2 for further details.
98
PADDLE(x)
PADDLE returns an integer value between 1 and 228 that
indicates the rotated position of the paddle connected to
paddle input x. The lowest values indicate a full clockwise
turn, and the higher values indicate full counterclockwise
turn. There is no meaningful relationship between the
values generated by the PADDLE function and the amount
of angular rotation.
Example:
FOR D=0TO 100+10*PADDLE(0):NEXT D
That example executes a time-delay interval that becomes
shorter as paddle is rotated in a clockwise direction. The
function in this case could be controlling the speed of a
missile figure on the screen.
PEEK(addr)
PEEK is a special-purpose function that returns the decimal
value of the byte that is stored at memory address addr.
Example:
PRINT PEEK(88)+256*PEEK(89)
That statement PEEKs into RAM addresses 88 and 89, and
prints a decimal value that happens to indicate the starting
address of the current screen RAM.
PLOT co/,row
Abbreviation: PL.
The PLOT command sets up a graphics operation to plot a
character or pixel at the column/row location indicated
by col,row. Appropriate ranges for numeric expressions
col and row depend on the current graphics screen mode.
See Chapter 4 for further details.
99
POINT #c/ian^ecf,6yfe
Abbreviation: P.
The POINT statement adjusts the position of the disk-file
pointer for the specified channel, chan. The adjustment is
to sector sect and byte byte.
The complement of this statement is NOTE Neither is
available under ATARI DOS 1.0.
POKE addr,data
POKE is a special statement that sends a byte of data to the
designated memory-mapped address, addr. The data byte
must be a decimal integer value between and 255 and
addr may be a decimal address between and 65535 it is
the complement of the PEEK function.
However, POKEing data to ROM locations, control
blocks that are opened for input operations or to RAM
addresses where no physical RAM exists has no effect on
the system.
The user should avoid careless or indiscriminate use of
the POKE command, because POKEing into RAM ad-
dresses that have functions already assigned to them by
the operating system, BASIC or DOS, can cause a system
software "crash."
POP
POP is a special control command that, in effect, forces
the computer to abort the automatic return or looping
features of GOSUB, ON . . . GOSUB and FOR . . . NEXT
operations that are in effect at the time. It actually POPs
the return address off the top of the run-time stack.
Practical applications of POP generally concern tech-
niques for breaking out of a subroutine or FOR NEXT
loop under a prescribed condition. A general statement
imbedded within a subroutine or FOR . . NEXT Iood
might look like this:
IF condition THEN POP:GOTO line number
100
If the designated condition is satisfied, the POP statement
effectively clears the way for doing a GOTO to some pro-
gram line number that is outside the subroutine or loop.
The program will then progress as though the GOSUB or
FOR . . . NEXT loops were never initiated.
Use POP statements sparingly and with care, especially
in programs that use extensively nested GOSUBs and
FOR . . . NEXT loops.
POSITION col,row
Abbreviation: POS.
The POSITION statement moves the print cursor directly
to the column/row screen position as designated by the
col and row values or expressions. The range of values that
are available for this statement varies with the screen
mode. See Chapter 4 for examples and further details.
PRINT expr list
Abbreviations: PR. or ?
PRINT is a statement that is used for printing information
to the video display. It can print lists of numeric constants
and expressions as well as string constants and expressions.
If the items in the expr list are separated by a semicolon,
the printing of one item begins immediately after the end
of a previous one. If the items are separated by a comma,
each is printed at the beginning of the next-available tab-
stop column on the screen.
The following version of the print statement transfers
numeric or string data to an lOCB channel:
PRINT #chan; . . .
See Chapter 6 for details.
PTRIG X
PTRIG returns a value of or 1, depending on whether the
pushbutton on paddle device x is pressed or not pressed.
101
Example:
IFPTRIG 1=0 THEN END
That short routine will end the program if the player
happens to be pressing the pushbutton on paddle device
1 when the conditional statement is executed.
PUTttchanA
Abbreviation: PU.
The PUT statement outputs a single integer value or
expression, x, to the designated lOCB channel, c/ian. It is
the funrtional complement of the GET statement.
See Chapter 6 for examples and further details.
RAD
RAD is a statement or command that converts all subse-
quent expressions of angles to units of radians. Executing a
RUN command automatically sets the RAD mode, and you
must include a DEC statement into the program whenever
you want to work with the degrees format.
READ varl, var2 . . .
Abbreviation: REA.
READ statements must be used in conjunction with DATA
statements. The statement sequentially reads items in
DATA lines and assigns them to the specified string or
numeric variables. The variable types must match; that is,
a READ A$statement expects a string value from the DATA
list, and a READ X statement expects a numeric value.
Compounded READ statements may mix variable types as
long as the corresponding sequence of DATA items fol-
lows the same format.
For example, this combination of READ/DATA state-
ments will work:
10 DIM A$(4)
20 READ A$,X
30 DATA BOY, 10
102
but this one will not, because it attempts to assign a string
constant, GIRL, to a numeric variable, X:
10 DIM A$(4)
20 READ A$,X
30 DATA BOY,GIRL
It might appear that the next example would return a
type-mismatch error, but it does not. The numbers as-
signed to A$ and B$, however, will be regarded as string
constants.
10 DIM A$(4),B$(4)
20 READA$,B$
30 DATA 5,6
Remember that numbers can be regarded as either
numeric or string constants, while string values can be
regarded only as strings.
REM
Abbreviations: R. or a period followed by a space
REM is a nonexecutable statement that allows you to
insert printed text, or REMarks, within a program listing.
Examples:
10 REM ** COUNT TO TEN **
1 00 R. NOTE: BEGIN PRINTER ROUTINE HERE < < <
RESTORE line number
Abbreviation: RES.
RESTORE is a program command that allows a DATA list to
be READ, beginning from the DATA line having the
designated line number. If line number is omitted from
the command, the next READ operation will begin from
the lowest-numbered DATA line.
103
RETURN
Abbreviation: RET.
RETURN is a program-control command that returns
operations from a subroutine to the statement following
the corresponding GOSUB. The command is meaningless
without a calling GOSUB or ON . . . GOSUB statement.
RND(x)
RND is a numeric function that returns a random-
number value that is equal to or greater than 0, but less
than 1. The x term is a dummy argument that has no effect
on the function, so it can have any numeric value.
Programs that use randomly generated numbers most
often require integer values and, even more often, values
that are larger than 1. The trick in such instances is to use a
function of this general form:
\NT{modu/us*HND(0) )+lownum
where modulus is the number of integers to be included
in the random series, and lownum is the lowest-valued
integer in the series. So if you want to generate random
integers between and 9, inclusively, modulus = 10 (there
are 10 different integers in the range of through 9) and
lownum = 0. The following program used that format to
print a series of 100 random integers separated by spaces:
10 FOR N=1 TO 100
20 PRINT INT(10*RND(0)); CHR$(32);
30 NEXT N
Or perhaps you need random integers between 50 and
100, inclusively. That represents a modulus of 51 and a
lownum of 50. To see a hundred such numbers:
10 FOR N=1 TO 100
20 PRINT INT(51*RND(0))+50; CHR$(32);
30 NEXT N
104
RUN [input device]
Abbreviation: RU.
Used without the optional input device specification,
RUN is a command that initiates the execution of the resi-
dent BASIC program from the lowest-numbered line. It
closes all I/O control channels and sets the trigonometric-
angle format to RAD (radians).
Alternatively, RUN input device erases any resident
BASIC programming, replaces it with a tokenized BASIC
program from the specified input device, and begins exe-
cuting the program from the lowest-numbered line.
Examples:
RUN
That command initiates execution of the resident BASIC
program from the lowest-numbered line.
RUN "D:FIXER"
That version loads a tokenized BASIC program named
FIXER from the default disk drive, and initiates execution
from the lowest-numbered line.
Use GOTO line number to begin execution of a resi-
dent program from some line number other than the
lowest-numbered line.
SAVE output device
Abbreviation: S.
SAVE is a command that transfers tokenized BASIC pro-
gramming from the computer to the specified output
device.
See Chapter 1 for examples and further details.
105
SETCOLOR reg, hue, lum
Abbreviation: SE.
SETCOLOR sets color register reg to the specified hue
and luminance values, hue and lum.
The value assigned to reg must specify one of the five
color registers: 0,1,2,3, or 4.
The value assigned to hue ought to be a positive integer
between and 15. The colors vary in brightness, or shade,
according to the subsequent lum value, so the following
list of hue values and colors is determined with the
assumption that the lum value is 0.
It is possible to specify a lum value as any positive
integer. The lowest-valued lum factors that cover the
entire luminance range are even numbers between and
14, inclusively; where sets up the darkest shade and 14
sets up the lightest.
See Chapter 4 for tables of hue and luminance values.
SGN(x)
SGN(x) is a numeric function that returns integer values of
-1, 0, or 1, depending on the sign of x; where x is any
floating-point constant or numeric expression.
If X is negative, SGN(x) returns a value of -1
If X is equal to 0, SGN(x) returns a value of
If X is positive, SGN{x) returns a value of 1
SIN(x)
SIN(x) is a numeric function that returns the trigono-
metric sign value of angle x; where x is any floating-point
constant or numeric expression. The angle is normally
assumed to be expressed in radian measure, but it can be
expressed in degrees by preceding the function with a
DEC command.
106
SOUND voice, pitch, disUvol
Abbreviation: SO.
The SOUND statement causes a tailored sound to be pro-
duced at the loudspeaker in the tv receiver or monitor.
The four arguments voice, pitch, dist, and vol determine
the voice, pitch, amount of distortion, and volume,
respectively.
There are four voices that are numbered through 3. It
is possible to select any combination of them. The pitch is
set by assigning an integer value between and 255,
where is the highest available pitch and 255 is the lowest.
See Chapter 7 for a table of pitch values and correspond-
ing musical notes.
The distortion figure determines the amount of noise,
or tonal distortion, that is injected into the sound. The
values must be even-numbered integers, where the lower
values produce more distortion than the higher values do.
The volume of the sound is set by assigning integer
values between and 15, where a value of completely
silences the voice, and 15 produces the loudest sound.
Once a SOUND command is executed, it generates its
sound until that voice is told to do otherwise, or you exe-
cute certain commands that affect the normal operation
of BASIC programs.
See Chapter 7 for examples and further details.
SQR(x)
SQR(x) is a numeric function that returns the square-root
of x; where x is any positive-valued, floating-point con-
stant or numeric expression.
107
STATUS itchan, numvar
Abbreviation: ST.
STATUS assigns the status code of the last-used lOCB
channel, chart, to a numerical variable, numvar. Table 3-2
lists the status codes and their interpretations.
Table 3-2. Status Codes That Are Returned by the
STATUS Command
Code
001
003
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
160
161
162
163
164
165
166
167
168
169
170
171
Meaning
Operation complete (no errors)
End of file (EOF)
BREAK executed
lOCB channel already in use (OPEN)
Nonexistent device
Opened for WRITE only
Invalid command
Device or file not open
Invalid lOCB channel number
Opened for READ only
End of file (EOF) encountered
Truncated record
Device timeout (doesn't respond)
Device NAK
Serial bus input framing error
Cursor out of range
Serial bus data frame overrun error
Serial bus data frame checksum error
Device-done error
Bad screen mode
Function not supported by handler
Insufficient memory for screen mode
Disk drive number error
Too many open disk files
Disk full
Fatal disk I/O error
Internal file number mismatch
Filename error
Point data length error
File locked
Command invalid for disk
Disk directory full
File not found
Point invalid
108
STEP
STEP is an optional part of a FOR . . . NEXT statement,
and thus does not function alone. See FOR.
Sl\CK(Jsno)
STICK returns one of eight different integer values that
indicate the position of the joystick handle connected to
joystick input number jsno. Fig. 3-1 shows the joystick
positions and their values.
*-7
Fig. 3-1 . Joystick positions and the values returned by the joystick
statements.
The relationships between ysno and the game-controller
connections are:
Controller jsno
1
2 1
3 2
4 3
Example:
IF STICK(0)=14THEN DY=DY+1
109
That conditional statement will increment the value of DY
if the joystick that is conneaed to game controller #1 is
pushed straight up.
STRIG(;sno)
STRIG refers to the condition of the pushbutton on the
joystick that is connected to game controller numberysno.
The statement returns a value of whenever the pushbut-
ton is depressed, and a value of 1 whenever it is not
depressed. (See a table of game-controller input numbers
andysno under STICK.)
STOP
Abbreviation: STO.
The STOP command halts the execution of a program and
causes the computer to return a message, STOPPED AT
LINE STOP does not close any files, so the program
can be resumed from the STOP command by entering the
CONT command.
STOP is often inserted temporarily into a program to
halt program operations for debugging purposes. It is
rarely included in programs that are intended for use by
anyone but the programmer.
STR$(x)
STR$ converts any valid, floating-point numeric value, x,
to a string equivalent.
See Chapter 2 for a detailed discussion of numeric and
string values.
THEN
THEN is an integral part of IF . . . THEN conditional
statements, and makes no sense without the IF statement
See IF.
TO
TO is an integral part of a FOR . . . NEXT statement, and
thus makes no sense outside that context. See FOR.
110
TRAP lineno
Abbreviation: T.
The TRAP statement is used for dealing with statements
that might otherwise cause annoying error-message inter-
rupts. A classic instance appears in the following routine:
10 PRINT "ENTER A NUMBER"
20 INPUT X
30 PRINT 1 /X
40 GOTO 10
The idea is simple: prompt the user to enter a number,
then display its inverse — that number divided into 1. Ever-
ything works fine until the user enters a 0. That brings up a
divide-by-0 error signal.
The following modification uses a TRAP statement to
deal with that situation in a far more graceful fashion:
10 PRINT "ENTER A NUMBER"
20 INPUT X
25 TRAP 100
30 PRINT 1 /X
40 GOTO 10
100 PRINT "INFINITY"
120 GOTO 10
A TRAP statement must always precede the statement that
contains the potential error situation — at line 25 in this
instance. The lineno portion of the TRAP statement directs
program operations to that line, but only in the event of
an error condition. This program will "trap" to line 100
only if the operator happens to enter a in response to
the INPUT statement in line 20.
A truly professional piece of BASIC programming will
use TRAP statements to avoid error problems whenever
users are not running the system properly. Commercial
software should never "crash" because of an error-
producing situation that can be dealt with more gracefully
with TRAP routines.
Ill
USR(addr)
The USR function directs the computer out of BASIC and
to a machine-language routine that begins at address
addr. Assuming that the machine-language programming
is properly structured, the computer will execute the pro-
gram and return to BASIC at the statement following the
USR.
It is possible to carry any number of numeric values, or
2-byte memory addresses that point to numeric or string
values, by adding appropriate arguments to the USR func-
tion. Those arguments are placed, in right-to-left order,
on the system's hardware stack. Consider this example:
USR(7148,128,ADR(M$))
This USR function calls a machine-language subroutine
that begins at decimal memory address 7148. It first pushes
the line number for the next BASIC command onto the
hardware stack, followed by the value returned by the
ADR(M$) function (the memory address of the content of
string variable M$), a 2-byte version of constant 128 and,
finally, a 1-byte integer indicating the number of argu-
ments in the function. The actual machine-language rou-
tine is then run.
An assembly language RET returns operations to the
BASIC instruction line that was originally pushed onto the
stack. The assumption, however, is that the instruction line
number is now residing on the top of the stack; and that
suggests that all other data, including that pushed to the
stack by the USR function, itself, must be pulled off before
executing the RET instruction.
See Chapter 7 for examples and further details.
112
VAL(x$)
VAL converts numerals that are represented in a string
format, x$, into their corresponding numeric value, it is
the inverse of the STR$(x) function.
XIO cmd, #chan, parami, paraml, dev
Abbreviation: X.
The XIO command might well be the most versatile I/O
command in ATARI BASIC. It can direct the flow of data
into and out of any available lOCB channel, work with any
sort of computer-compatible device, format special serial
operations, and even fill in blocks of graphics on the
screen.
See Chapter 6 for a special treatment of this command,
including tables that define its parameters.
113
Chapter 4
The Text and Graphics Screens
The ATARI system features 8 different screen modes and
21 meaningful variations of them. Table 4-1 summarizes
those screen formats.
Modes 0, 1, and 2 are usually classified as text and char-
acter modes, primarily because they are used for printing
characters from a well-defined, bit-mapped character set.
Modes 3 through 8, and their variations, are regarded as
graphics modes because they plot pixels of color to the
screen. The graphics modes are further divided into 4-
color, 2-color, and 1-color modes. The discussions in this
chapter are organized according to these classifications.
FEATURES COMMON TO ALL SCREEN MODES
Hue and luminance values, and the RAM addresses of the
five color registers, are common to all ATARI screen
modes. Table 4-2 lists the hue values. Table 4-3 shows the
luminance values, and Fig. 4-1 shows the basic arrange-
ment of the color registers and their RAM addresses.
NOTE: Color is defined throughout this book as the combi-
nation of hue and luminance values. There are 76 possible
hue values and 8 luminance values; and that implies that
ATARI graphics features 128 basic colors.
115
Table 4-1. Summary of ATARI
Home Computer Screen Modes
Graphics
Size
Text Window
Mode
(col X row)
(col X row)
Notes
40X24
—
Text only
1
20X20
40X4
Expandid chara(!ters
with text window
2
20 X 10
40X4
Expanded characters
with text window
3
40X20
40X4
Low-resolution, 4-
color graphics with
text window
4
80X40
40X4
Medium-resolution,
2-color graphics with
text window
5
80X40
40X4
Medium-resolution, 4-
color graphics with
text window
6
1 60 X 80
40X4
High-resolution, 2-
color graphics with
text window
7
1 60 X 80
40X4
High-resolution, 4-
color graphics with
text window
8
320 X 1 60
40X4
Very high resolution,
2-color graphics with
text window
17
20X24
none
Same as Mode 1
without text window
18
20X 12
none
Same as Mode 2
without text window
19
40X24
none
Same as Mode 3
without text window
20
80X48
none
Same as Mode 4
without text window
21
80X48
none
Same as Mode 5
without text window
22
1 60 X 96
none
Same as Mode 6
without text window
23
1 60 X 96
none
Same as Mode 7
without text window
24
320X192
none
Same as Mode 8
without text window
116
Table 4-1— cont. Summary of ATARI
Home Computer Screen Modes
Graphics
Size
Text Window
Notes
Mode
(col X row)
(col X row)
32
40X24
—
Same as Mode
without screen clearing
33
20X20
40X4
Same as Mode 1
without screen clearing
34
20X10
40X4
Same as Mode 2
without screen clearing
35
40X20
40X4
Same as Mode 3
without screen clearing
36
80X40
40X4
Same as Mode 4
without screen clearing
37
80X40
40X4
Same as Mode 5
without screen clearing
38
160X80
40X4
Same as Mode 6
without screen clearing
39
160X80
40X4
Same as Mode 7
without screen clearing
40
320 X 1 60
40X4
Same as Mode 8
without screen clearing
49
20X24
none
Same as Mode 1 7
without screen clearing
50
20X12
none
Same as Mode 1 8
without screen clearing
51
40X24
none
Same as Mode 19
without screen clearing
52
80X48
none
Same as Mode 20
without screen clearing
53
80X48
none
Same as Mode 21
without screen clearing
54
1 60 X 96
none
Same as Mode 22
without screen clearing
55
1 60 X 96
none
Same as Mode 23
without screen clearing
56
320 X 192
none
Same as Mode 24
without screen clearing
117
Table 4-2. Standard ATARI Home Computer Hue
Values and Those Values as Multiplied by 16
Color
Black
Brown
Red-orange
Dark orange
Red
Deep lavender
Deep blue-green
Ultramarine blue
Medium blue
Deep blue
Blue-gray
Olive
Medium green
Deep green
Orange-green
Orange
Hue
Value
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16*Hue
Value
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
NOTE: All color values assume a luminance of 0. Their actual
appearance depends on the color adjustments on the tv or monitor, and
the names, themselves, are subject to personal interpretation.
Table 4-3. Relevant Luminance Values
Relative
Luminance
Darkest
Lightest
Value
2
4
6
8
10
12
14
NOTE: Odd-numbered integers in the range of 1 through 1 5 produce the
same luminance as the preceding even-numbered value.
118
Fig. 4-1 . The five standard color
registers and their deci-
mal RAM addresses.
REGISTER
ADDRESS 708
REGISTER 1
ADDRESS 709
REGISTER 2
ADDRESS 710
REGISTER 3
ADDRESS 711
REGISTER 4
ADDRESS 712
The ATARI system uses a ROM-based character set that
is used for plotting text characters and a handful of special
graphics characters. Each character has a code number
assigned to it, but there are two different coding schemes.
One coding scheme, shown in Table 4-4, uses code
numbers that are closely related to the customary ASCII
format (the addition of some special graphics characters
prompts most writers to refer to it as the ATARI ASCII, or
ATASCII, character set). These are the character codes that
are relevant to BASIC functions such as CHR$ and ASC.
Table 4-5 shows the ATARI internal character set and
corresponding codes. These are the values that are actu-
ally carried as data in the screen RAM address locations;
and from a programmer's point of view, they are the
values that are most relevant when POKEing and PEEKing
characters into the screen RAM area. The table does not
include the inverse characters, but they are plotted by
setting the most-significant bit of the character data byte
to 1, or adding 128 to the code numbers shown here.
Generally speaking, the print cursor is a mechanism that
points to a position on the screen when the next character
or pixel of color is to be plotted. All screen modes share
several sets of registers that are directly related to the posi-
tion of the print cursor, and the addresses and functions
are summarized for you in Table 4-6.
119
Table4^. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
^
NUL
CTRL-,
1
h
SOH
CTRL-A
2
1
STX
CTRL-B
3
J
ETX
CTRL-C
4
H
EOT
CTRL-D
5
n
ENQ
CTRL-E
6
/'
ACK
CTRL-F
7
\
BEL
CTRL-G
8
^
BS
CTRL-H
9
■
HT
CTRL-I
10
k
LF
CTRL-J
11
■
VT
CTRL-K
12
■
FF
CTRL-L
13
^
CR
CTRL-M
14
—
SO
CTRL-N
15
■
SI
CTRL-0
16
.
4-
DLE
CTRL-P
17
-
r
DC1
CTRL-Q
120
Table 4-4— cont. The ATASCM-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
18
19
+
20
•
21
^
22
1
23
T
24
J.
25
26
1
27
«:
28
t
29
«
30
■C-
31
-»■
32
33
i
34
:t
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
(space)
I
CTRL-R
CTRL-S
CTRL-T
CTRL-U
CTRL-V
CTRL-W
CTRL-X
CTRL-Y
CTRL-Z
ESC/ESC
ESC/CTRL--
ESC/CTRL- =
ESC/CTRL-
ESC/CTRL-'
Space Bar
SHIFT-1
SHIFT-2
121
Table 4-4— cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
^r
#
$
%
&
(
)
*
+
/
1
2
3
SHIFT-3
SHIFT-4
SHIFT-5
SHIFT-6
SHIFT-7
SHIFT-9
SHIFT-0
»
+
/
1
2
3
.±
:
(
'l
-yr
•f
»
..„
*
y'
1
-:
122
Table 4-4— cont. The ATASCII-Coded Character Set
Code
AT ASCI I
Character
ASCII
Character
or Control
Keystroke(s)
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
ij
<
>
7
@
A
B
C
D
4
5
6
7
8
9
SHIFT-;
<
>
SHIFT-/
SHIFT-8
A
8
C
D
123
Table 4-4— cont. The ATASCII-Coded Character Set
Code
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
ATASCII
Character
U
M
I.!
ASCII
Character
or Control
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
Keystroke(s)
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
124
Table 4-4
— cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
86
u
V
V
87
N
W
W
88
)•:;'
X
X
89
y
Y
Y
90
Z
Z
91
L
[
SHIFT-
92
\
\
SHIFT-,
93
J
]
SHIFT- +
94
-
SHIFT-*
95
—
SHIFT -
96
«
N
CTRL-
97
3
a
LOWRA
98
D
b
LOWRB
99
C
c
LOWRC
100
d
d
LOWRD
101
9
e
LOWRE
102
T
f
LOWRF
125
Table 4-4-cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
103
9
9
LOWRG
104
h
h
LOWRH
105
1
i
LOWRI
106
J
J
LOWRJ
107
k
k
LOWRK
108
1
1
LOWRL
109
fi
m
LOWRM
110
n
n
LOWRN
111
o
o
LOWRO
112
p
P
LOWRP
113
H
q
LOWRQ
114
r
r
LOWRR
115
s
s
LOWRS
116
t
t
LOWRT
117
u
u
LOWRU
118
V
V
LOWRV
119
w
w
LOWR W
126
Table 4-4— cont.
The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
120
••.••
X
LOWRX
121
3
y
LOWRY
122
"-
z
LOWRZ
123
«
1
CTRL-;
124
1
1
SHIFT- =
125
If
1
ESC/CTRL-<
126
4
~
ESC/BACK S
127
¥
DEL
ESC/TAB
128
□
NUL
(A) CTRL-,
129
o
SOH
(A) CTRL-A
130
m
STX
(A) CTRL-B
131
a
ETX
(A) CTRL-C
132
a
EOT
(A) CTRL-D
133
a
ENQ
(A) CTRL-E
134
Q
ACK
(A) CTRL-F
135
O
BEL
(A) CTRL-G
136
n
BS
(A) CTRL-H
127
Table 4-4-cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
137
r
HT
(A) CTRL-I
138
a
LF
(A) CTRL-J
139
B
VT
(A) CTRL-K
140
a
FF
(A) CTRL-L
141
H
CR
(A) CTRL-M
142
m
SO
(A) CTRL-N
143
a
SI
(A) CTRL-0
144
□
OLE
(A) CTRL-P
145
D
DC1
(A) CTRL-Q
146
B
DC2
(A) CTRL-R
147
a
DC3
(A) CTRL-S
148
a
DC4
(A) CTRL-T
149
n
NAK
(A) CTRL-U
150
m
SYN
(A) CTRL-V
151
a
ETB
(A) CTRL-W
152
a
CAN
(A) CTRL-X
153
3
EM
(A) CTRL-Y
128
Table 4-4— cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystrokels)
154
D
SUB
(A) CTRL-Z
155
B
ESC
(A) RETURN
156
□
FS
ESC/SHIFT-BACK S
157
U
GS
ESC/SHIFT->
158
Ea
RS
ESC/CTRL-TAB
159
□
US
ESC/SHIFT-TAB
160
■
(space)
(A) Space Bar
161
■
!
(A) SHIFT-1
162
H
"
(A) SHIFT-2
163
m
#
(A) SHIFT-3
164
B
$
(A) SHIFT-4
165
H
%
(A) SHIFT-5
166
H
&
(A) SHIFT-6
167
■
'
(A) SHIFT-7
168
H
(
(A) SHlFT-9
169
H
)
(A) SHIFT-0
170
Kl
»
(A) »
129
Table 4-4— cont. The ATASCII-Coded Character Set
Code
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
ATASCII
Character
ASCII
Character
or Control
/
1
2
3
4
5
6
7
8
9
Keystroke(s)
(A) +
(A) .
(A) _
(A) ■
(A) /
(A)
(A)
1
(A)
2
(A)
3
(A)
4
(A)
5
(A)
6
(A)
7
(A)
8
(A)
9
(A)
SHIFT-;
(A)
130
Table 4-4— cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
188
■
<
(A) <
189
B
=
(A) =
190
H
>
(A) >
191
H
?
(A) SHIFT-/
192
H
@
(A) SHIFT-8
193
H
A
(A) A
194
H
B
(A) B
195
H
C
(A) c
196
H
D
(A) D
197
HI
E
(A) E
198
B
F
(A) F
199
H
G
(A) G
200
b9
H
(A) H
201
H
1
(A) 1
202
■
J
(A) J
203
B
K
(A) K
204
B
L
(A) L
131
Table 4-4-cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
205
B
M
(A) M
206
m
N
(A) N
207
B
(A)
208
B
P
(A) P
209
B
Q
(A) Q
210
B
R
(A) R
211
B
S
(A) s
212
B
T
(A) T
213
■
U
(A) u
214
H
V
(A) V
215
Ml
w
(A) w
216
B
X
(A) X
217
B
Y
(A) Y
218
H
z
(A) z
219
B
[
(A) SHIFT-,
220
B
\
(A) SHIFT-+
221
B
]
(A) SHIFT-.
132
Table 4-4— cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
222
■
&
(A) SHIFT-*
223
■
—
(A) SHIFT-
224
□
V
(A) CTRL-.
225
H
a
(A) LOWR A
226
H
b
(A) LOWRB
227
B
c
(A) LOWR C
228
H
d
(A) LOWRD
229
H
6
(A) LOWR E
230
H
f
(A) LOWRF
231
m
9
(A) LOWR G
232
m
h
(A) LOWRH
233
m
i
(A) LOWR 1
234
m
J
(A) LOWR J
235
H
k
(A) LOWR K
236
H
1
(A) LOWRL
237
ei
m
(Jl^) LOWR M
238
B
n
(A) LOWRN
133
Table 4-4-cont. The ATASCII-Coded Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
239
H
(A) LOWRO
240
H
P
(A) LOWRP
241
H
q
(A) LOWRQ
242
H
r
(A) LOWRR
243
B
s
(A) LOWR S
244
H
t
(A) LOWRT
245
B
u
(A) LOWRU
246
B
V
(A) LOWRV
247
B
w
(A) LOWRW
248
B
X
(A.) LOWRX
249
B
y
(A) LOWRY
250
H
z
(A) LOWRZ
251
□
1
(A) CTRL-;
252
B
1
(A) SHIFT- =
253
□
)
ESC/CTRL-2
254
□
_
(Jl^^) ESC/CTRL-BACK S
255
a
DEL
(A) ESC/CTRL->
134
Table 4-5. The ATARI'
s Internal Character Set
Code
Character
ROM Addresses
Start
End
57344
57351
1
1
57352
57359
2
ii
57360
57367
3
i^
57368
57375
4
'?■
57376
57383
5
57384
57391
6
>•:'.
57392
57399
7
:
57400
57407
8
r"
57408
57415
9
'i
57416
57423
10
7"r
57424
57431
11
•f
57432
57439
12
♦
57440
57447
13
—
57448
57455
14
*
57456
57463
15
..••■'
57464
57471
135
Table 4-5— cont. The ATARI'S Internal Character Set
Code
Character
ROM Addresses
Start
End
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
57472
57480
57488
57496
57504
57512
57520
57528
57536
57544
57552
57560
57568
57576
57584
57592
57479
57487
57495
57503
57511
57519
57527
57535
57543
57551
57559
57567
57575
57583
57591
57599
U.
3
•^
5
o
7
8
•y
*
<
-•-
y'
9
136
Table 4-5— cont. The ATARI'S internal Character Set
Code
Character
ROM Addresses
Start
End
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ij
n
R
M
57600
57608
57616
57624
57632
57640
57648
57656
57664
57672
57680
57688
57696
57704
57712
57720
57607
57615
57623
57631
57639
57647
57655
57663
57671
57679
57687
57695
57703
57711
57719
57727
137
Table 4-5-
-cont
. The ATARI'S Internal Character Set
Code
Character
ROM Addresses |
Start
End
48
;;.
57728
57735
49
Q
57736
57743
50
R
57744
57751
51
57752
57759
52
T
57760
57767
53
U
57768
57775
54
u
57776
57783
55
57784
57791
56
57792
57799
57
Y
57800
57807
58
2
57808
57815
59
C
57816
57823
60
■••..
57824
57831
61
3
57832
57839
62
••■'■••
57840
57847
63
....
57848
57855
138
Table 4-5— cont. The ATARI'S Internal Character Set
Code
Character
ROM Addresses
Start
End
64
□
57856
57863
65
D
57864
57871
66
n
57872
57879
67
a
57880
57887
68
El
57888
57895
69
a
57896
57903
70
a
57904
57911
71
□
57912
57919
72
n
57920
57927
73
r
57928
57935
74
n
57936
57943
75
B
57944
57951
76
a
57952
57959
77
B
57960
57967
78
B
57968
57975
79
9
57976
57983
139
Table 4-5— cont. The ATARI'S Internal Character Set
Code
Character
ROM Addresses
Start
End
80
□
57984
57991
81
D
57992
57999
82
D
58000
58007
83
n
58008
58015
84
n
59016
58023
85
H
58024
58031
86
n
58032
58039
87
II
58040
58047
88
ca
58048
58055
89
a
58056
58063
90
D
58064
58071
91
B
58072
58079
92
□
58080
58087
93
□
58088
58095
94
a
58096
58103
95
□
58104
58111
140
Table 4-5— cont. The ATARI'S Internal Character Set
Code
ROM Addresses
Start
End
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
□
58112
58120
58128
58136
58144
58152
58160
58168
58176
58184
58192
58200
58208
58216
58224
58232
58119
58127
58135
58143
58151
58159
58167
58175
58183
58191
58199
58207
58215
58223
58231
58239
3
b
c
d
e
T
9
h
i
J
k
i
n
n
o
141
Table 4-5— cont. The ATARI'S Internal Character Set
Code
Character
ROM Addresses
Start
End
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
H
t
!!
Ui
US
58240
58248
58256
58264
58272
58280
58288
58296
58304
58312
58320
58328
58336
58344
58352
58360
58247
58255
58263
58271
58279
58287
58295
58303
58311
58319
58327
58335
58343
58351
58359
58367
142
Table 4-6. Cursor-Position Registers
Label
Address
Purpose
ROWCRS
COLCRS
OLDROW
OLDCOL
NEWROW
NEWCOL
TXTROW
TXTCOL
CRSNH
84
85
86
90
91
92
96
97
98
656
657
658
752
Row location of the active cursor
LSB of column location of the
active cursor
MSB of column location of the
active cursor
Current row location of the drawing
cursor
LSB of current column location of
the drawing cursor
MSB of the current column location
of the drawing cursor
Destination row location for the
drawing cursor
LSB of destination column location
of the drawing cursor
MSB of destination column location
of the drawing cursor
Swapped text/drawing row location
of the cursor
LSB of swapped text/drawing column
location of the cursor
MSB of swapped text/drawing column
location of the cursor
Cursor inhibit; 0=ON, 1=0FF
Cursor-related BASIC statements make full use of those
registers, and it is possible to POKE new cursor positions
into them.
MODE-0 GRAPHICS
The Mode-0 screen is the most-used text screen, and it is
the system's default screen. Its characteristics apply to the
text-window portion of other screen modes that use the
split-screen feature.
It is usually adequate to enter this screen mode by doing
a ■i*'«aiaMriaaaw keystroke, but a few lesser-used text
operations are valid only by first executing the GRAPHICS
command, or opening lOCB Channel 6 for read/write
operations for the screen device.
143
Organization of the iVIode-O Color Registers
Fig. 4-2 shows the organization of the ATARI'S five color
registers for the Mode-0 text screen. The same organiza-
tion, incidentally, applies to the text-window portions of
other split-screen graphics modes.
MODE-O
USAGE
NOT USED
REGISTER
ADDRESS 708
CHARACTER
LUMINANCE
REGISTER 1
ADDRESS 709
CHARACTER HUE
AND BACKGROUND
COLOR
REGISTER 2
ADDRESS 710
NOT USED
REGISTER 3
ADDRESS 711
BORDER
COLOR
REGISTER 4
ADDRESS 712
Fig. 4-2. Organization of color registers for the IUode-0 text screen.
Color register 1 carries the luminance value for the text
characters. The hue value assigned to Register 2 applies to
both the background and foreground characters, while
the luminance value applies only to the background. It is
thus impossible to assign different hue values to the
Mode-0 characters and background; the relative lumi-
nance values assigned to registers 1 and 2 determine the
contrast between the background and characters.
Register 4 carries the full color definition for the Mode-
border.
From BASIC, the Mode-0 color registers can be set by
applying the SETCOLOR statement or by POKEing the
appropriate data directly into the registers. The registers
can, of course, be directly loaded from a machine-
language program as well.
144
The SETCOLOR statement refers directly to the color-
register number, hue values and luminance values:
SETCOLOR 1,0,/um
SETCOLOR 2,huejum
SETCOLOR 4,huejum
Those three statements, in turn, set the luminance of the
foreground characters, the background color and charac-
ter hue, and the border color.
When using POKE statements to set the color registers,
the addr portion of the statement refers to the address of
the color register and the data portion refers to the overall
color designation: 16*/iue + lum. So in a general sense, a
POKE statement for setting the color registers takes this
form:
POKE addrA6*hue + lum
The following POKE statements, in turn, set the lumi-
nance of the foreground characters, the background color
and character hue, and the border color.
POKE 709,/um
POKE 710,16*hue + lum
POKE 712,16*/iue + /urn
Working With the Mode-0 Column/Row Format
Fig. 4-3 shows the Mode-0 screen as organized in a
column/row format, it shows 40 columns (labeled
through 39) and 24 rows (labeled through 23). That is, in
a manner of speaking, the equivalent of a horizontal-
vertical coordinate system; and it is most convenient
when using BASIC statements that refer directly to col and
row parameters and use the print-cursor features.
145
??-
~
—
—
—
n-
~
~
—
~
~~
—
S-
~
^-
M-
~
'^-
~
~
'di-
"~
^-
CM-
CVJ"
~
~
■~
~
~
~
^-
~
~
—
W-
~
—
^-
~
<N-
~
C\J~
CM-
~
^-
-
0)_
^
~
"
_
~~
^-
~
—
~
Oi-
~
00-
h--
—
—
—
(D-
~
~
lO-
■~
■V-
~
—
—
co-
CSJ-
_
T--
o-
, 1
i
/
r>
■M
1
1
1
1
1
1
1
1
1
I
ir
-r
T
I
"T
-r
--'-'- cgcgcgcM
MOU SOIHdVUD
Fig. 4-3. The column/row format for the Mode-0 text screen.
146
Basic's print statement provides the most convenient
means for printing text information to the Mode-0 screen.
Although the print cursor is normally invisible during the
execution of a program, every character that is PRINTed to
the screen affects the cursor's position. Generally, that
means plotting a character to the screen and then moving
the cursor to the next-available column location. If a line
of text happens to exceed column-location 39, printing
will resume from the first column in the next-available
row. The print cursor responds to an EOL (end-of-line)
character by moving to the beginning of the next-avail-
able line on the screen. End-of-screen scrolling is in effect
throughout Mode-1 text-printing operations.
In Mode 0, PRINT statements directly affect the cursor
locations in ROWCRS and COLCRS (see Table 4-6).
Working With the Mode-0 IVIargins
Normal Mode-0 PRINT operations do not print text into
the first two column locations of each line. The system
automatically assigns this 2-column margin at the left side
of the screen; and under those circumstances, PRINT
operations are confined to columns 2 through 39.
It is possible, however, to adjust those print margins by
POKEing some appropriate values into the following RAM
locations:
LMARGN 82 Column number of left margin
RMARGN 83 Column number of right margin
The default values for LMARGN and RMARGN are 2
and 39, respectively. You can PRINT into the full row by
eliminating the left margin:
POKE 82,0
Other margin settings are possible, but the column value
POKED to RMARGN must be greater than the value
POKED to LMARGN. Doing a BSBBJISO restores the
default text-margin settings.
147
Using the POSITION Statement
The POSITION coljow statement, when used with the
Mode-0 screen, refers directly to the screen's column/row
format. In that context, the values assigned to col and row
must be through 39 and through 23, respectively.
POSITION is most useful for formatting text on the
screen, and the statement makes it possible to see the
print cursor outside the current margin boundaries.
POSITION directly affects the values that are assigned to
the ROWCRS and COLCRS registers (see Table 4-6); and
one can, in fact, mimic the function of a POSITION state-
ment by POKEing the same col and row values into those
registers.
Alternative Column/Row Techniques
The matter of plotting text to the Mode-0 screen is not
limited to using PRINT statements. Three statements that
are normally regarded as purely graphics statements can
be used with the Mode-0 text screen as well: COLOR,
PLOT, DRAWTO and XIO 18.
NOTE: The COLOR, PLOT, DRAWTO and XIO 18 state-
ments function as described in Mode only if lOCB 6 is
open; and that is most easily accomplished by preceding
the operations with a CR.O command.
PLOT col,row is normally used for plotting a colored
pixel to the designated column/row coordinate of a graph-
ics screen. The color of the pixel in such instances is
determined by the most recently executed COLOR reg
statement, where reg refers to the color residing in a par-
ticular color register. Used with the Mode-0 screen, how-
ever, PLOT prints a single character to the designated
point on the screen, and the character that is thus printed
is determined by the most recent COLOR statement,
where the COLOR parameter is the ATASCII code number
(see Table 4-4). Consider the following sequence:
GR.0:COLOR 65:PLOT 10,5
148
That will print an upper-case letter A (ATASCII code 65) to
column 10, row 5.
And applying a bit of imagination, it is also possible to
create some special text effects with the DRAWTO state-
ment. Normally, DRAWTO col,row will draw a line of
color from a PLOT point to the designated column/row
coordinate. The last-executed COLOR statement deter-
mines the color of that line. When working with the
Mode-0 screen, however, the parameter assigned to the
COLOR statement determines the ATASCII character to
be plotted between PLOT-specified place and the DRA WTO-
specified place. The following routine plots lower-case
letter as from column 0, row to column 39, row 20:
GR.OiCOLOR 97:PLOT 0,0:DRAWTO 39,20
These operations do not affect the text-cursor registers,
ROWCRS and COLCRS; rather they work with OLDROW,
OLDCOL, NEWROW and NEWCOL (see Table 4-6).
The XIO 18 statement can fill a section of the screen
with a specified character. For example:
10 GRAPHICS
20 PLOT20,10:DRAWTO 20,0:DRAWTO 0,0:POSITION
0,10
30 POKE 765,97
40 XIO 18,#6,0,0,"S:"
Program line 10 sets screen (and opens lOCB #6 for
screen operations), and line 20 defines the outline of a
rectangular field on the screen. Line 30 POKEs the ATASCII
code for the desired character, and line 40 executes the
"fill" operation.
Using LOCATE, GET, and PUT in Mode-0
LOCATE, GET, and PUT also deal with the Mode-0 screen
in a column/row format; and like the graphics statements
described in the previous section, lOCB Channel 6 must
be open in order to use them.
149
Executing a PUT #6,x plots the ATASCII character
represented by code x to the screen. The position is
determined by the main print cursor registers, ROWCRS
and COLCRS, and the execution of the statement advan-
ces the cursor position. In this context, the PUT statement
is easier to use than the COLOR/PLOT combination.
The GET statement is the complement of PUT. Rather
than plotting a specified character to the current cursor
location, it returns the ATASCII code value of any charac-
ter that might be printed there. The general form is:
GET Ue.numvar
where numvar is a numerical variable that takes on the
ATASCII value determined by the GET statement.
The LOCATE function is quite similar to GET, but
LOCATE does not operate according to the current cursor
position. In fact, it operates entirely independent of it.
Executing a statement of this general form:
LOCATE co/,row,numvar
assigns the ATASCII code number of any character printed
to Mode-0 location coirow to numerical variable, num-
var.
The Mode-0 Screen RAM Format
It is quite often helpful to view the Mode-0 screen in
terms of the screen RAM addresses and data. Fig. 4-4
shows the addressing ranges for each line on the screen.
This view of the Mode-0 screen facilitates the use of
POKE and PEEK statements and machine-language rou-
tines for text operations. (The version in the Appendices
lists both the decimal and hexadecimal address locations.)
POKE and PEEK statements both refer to an address and
a byte of data that is associated with that address. The
address in this case refers to the absolute screen address
locations shown in the table; the data refers to the internal
character codes cited in Table 4-5.
150
oi o> O) a> o> oi a> o> ot o>0}o>a> Oi o> a>oia)0>a>Oia>aiO>
QOt-i-T-cMCMeococo'^^mmif)to(eh*r^h*ooooo>OJ
OOOOOOOOQOOOO OOOOOOOOOOO
I.I.I
tT ^ ^ ■* ^
1. 1. I.I .1
^ ^ ^ ^
1.1. 1 I
t- io o) rs r* T- IX)
N- r^ N- 00 CO o> OJ
^^ '^ \_/^^0000000
1 I I I I .1. I. I. I.I
111 \ I I I 1 rnm m i i i i i i i i i i i
OOQ OOOOOOOOOO OOOOOOOOOOO
O^OO raCDO^OOCMtOO^OO CM<DO^CO<M(DO^GOOi
go Q ^ y— ^ ^ p^ (fj {1^ i^ ^ .«. ,^N li^ /rt /rt #/\ K^ K^ r<\ f<\ ^ /^\
OO OOOOOOOOO
■^ ^ ^ -^ ■* ''t -<t
OO «. ^ ^
'^ m in <D <
O O O O '
O r- C4 CO^lOCDr^i
Fig. 4-4. Thescreen RAM addressformatfortheMode-Otextscreen.
151
Plotting a character to the screen is thus a matter of
executing a statement of this general form:
POKE addr,data
where addr is the screen address that represents the
desired printing location on the screen, and data is the
internal character code of the character to be printed
there. POKEing data values larger than 127 will print the
inverse version of the internal character set.
In this context, the following sort of PEEK statement
returns the internal-code value of the character residing at
the specified address:
PEEKiaddr)
MODE-1 AND MODE-2 GRAPHICS
Screen Modes 1 and 2 are expanded-text modes. Mode
1 expands the characters to twice their Mode-0 width, and
Mode 2 expands the characters to twice their Mode-0
width and height. Modes 1 and 2 both have a 4-line text
window along the bottom of the screen that is devoted to
text operations that are similar to those of the Mode-0
screen.
The normal procedure for setting up the expanded-text
modes is by executing a GRAPHICS 1 or GRAPHICS 2
command. In both instances, the system will clear the gra-
phics and text-window portions of the screen. A later dis-
cussion in this section describes how to set up versions
that do not have a text window, and enter one of the
expanded-text modes without clearing the screen. Initiat-
ing either expanded-text mode automatically opens lOCB
6 for the graphics portion of the screens.
152
Organization of the Mode-1 and Mode-2 Color Registers
Fig. 4-5 shows the organization of the ATARI'S five color
registers as applied to both Modes 1 and 2. The figure also
indicates the register organization for the text-window
portion of the screens.
TEXT WINDOW
USAGE
EXPANDED-CHARACTER
SCREEN
NOT USED
REGISTER
ADDRESS 708
UPPER-CASE LETTERS,
NUMERALS AND
PUNCTUATION
CHARACTER
LUMINANCE
REGISTER 1
ADDRESS 709
LOWER-CASE LETTERS
AND SPECIAL
GRAPHICS
CHARACTER HUE
AND BACKGROUND
COLOR
REGISTER 2
ADDRESS 710
INVERSE-VIDEO
VERSION OF
REGISTER
NOT USED
REGISTER 3
ADDRESS 711
INVERSE-VIDEO
VERSION OF
REGISTER 1
BORDER
COLOR
REGISTER 4
ADDRESS 712
BACKGROUND
COLOR
Fig. 4-5. Organization of the color registers for Modes 1 and 2.
Screen Modes 1 and 2 can use all five registers, with
register 4 determining the background color for the graph-
ics portion of the screen (which, incidentally, is the same
as the border color for the text window).
The graphics and text window also share registers 1 and
2, thus making it difficult to print a graphic from register 2
that has a color different from the text-window's back-
ground. Likewise, working with color register 1 in terms of
graphics will influence the luminance of the characters in
the text-window area.
From BASIC, the color registers can be set by applying
the SETCOLOR statement or by POKEing the appropriate
data directly into the registers.
153
The SETCOLOR statement works with the register color
in terms of separate hue and luminance values:
SETCOLOR reg,hue.lum
where reg is the register number (0 through 4), and hue
and /um values are specified according to Tables 4-2 and
4-3.
When using POKE statements to set the color registers,
the addr portion of the statement refers to the address of
the color register and the data portion refers to the overall
color designation: ^S*hue + lum. So in a general sense, a
POKE statement for setting the color registers takes this
form:
POKE addr A&* hue + lum
Accessing the Character Set From Modes 1 and 2
The graphics portion of the screen for Modes 1 and 2 uses
the same character set as Mode 1 and the text windows for
Modes 1 and 2. When working in the expanded-character
modes, however, it is not possible to access the entire
character set at any given moment— only one-half or the
other is available.
Unless directed otherwise, the system accesses only the
first 64 characters shown in Table 4-5 (internal codes
through 63). That includes all of the commonly used
numerals, punctuation and upper-case letters of the
alphabet. Whenever it is necessary to access the second
half of the character table (codes 64 through 127), the MSB
of that address of that part of the ROM table must be
POKEd into address 756.
154
NOTE: Unless you are using a custom character set (de-
scribed later in this chapter), the following POKE functions
are necessary only when printing text to the expanded-
character portion of screen Modes 1 and 2:
Access the characters for internal codes through 63 by
executing:
POKE 756,224
Access the characters for internal codes 64 through 127 by
executing:
POKE 756,226
It is not possible to print inverse versions of the
expanded characters.
Working With the Mode-1 and -2 Column/Row Format
Figs. 4-6 and 4-7 show the column/row formats for the
Mode-1 and Mode-2 screens, respectively. Both have a 40
column, 4-row text window, but the expanded-character
portions are different. The Mode-1 screen uses a 20-
column, 10-row format, while the Mode-2 screen uses a
20-column, 20-row format.
Although it is also possible to regard these screens from
a RAM address format, the column/row format is more
appropriate when working with BASIC statements that
refer directly to col and row parameters and use the print-
cursor features.
BASIC'S PRINT statement provides the most convenient
means for printing characters to both portions of the
Mode-1 and -2 screens. The expanded-character and text-
window portions use a different PRINT syntax and differ-
ent cursor-position registers.
155
2§
5
N
0>_
~
-S
CO —
-S
l^_
^■^
<o_
_CM
lf)-_
-s
•^_
eg
CD
-s
o_
en-
OS—
h
Z
s
-a
3
o
z
f/t
-1
o
<>
u
(1
<
1-
o
to —
—CM
lO —
— O
■* —
—00
CO-
— (O
CM—
— ^
^_
— CM
o —
I
, 1
1
1 1
— O
/
"I
O
1
1
1
1
11 1 1 1 1 1 1 1 I I
m<Of^ooo»oi-cgc5^io
I-
r
1
X)
1
J>
r
r
CO
CM
\
MOU SOIHdVUO
Fig. 4-6. Column/row format for screen Mode 1 .
156
when working with split-screen Modes 1 and 2, ordi-
nary PRINT statements refer to the text window and use
the TXTCOL and TXTROW registers for keeping track of
the text window cursor position (see Table 4-6).
But the printing operations for the expanded-character
portion of the screen uses lOCB Channel 6. So any PRINT
operation to that part of the screen must use a PRINT #6
statement. The general syntax is:
PRINT #6;/re/n
where item is a valid PRINT constant or variable.
Printing operations to the expanded-character screen
use cursor-position registers ROWCRS and COLCRS.
The expanded-character and text window portions of
the screens thus use different cursor registers. Both sets of
registers keep track of their respective cursor locations
and carry out automatic operations, such as advancing the
cursor after printing each character. The text window has
a vertical scrolling feature, but the expanded-character
portion of the screen does not. It is also possible to adjust
the margin settings for the text window (as described for
Mode-0 operations), but the expanded-character part of
the screen has no margin feature at all.
Using a PRINT #6 statement to print characters directly
to the expanded-character portion of the screen causes
some potentially troublesome, but generally manageable,
character and color effects. What is prescribed by a PRINT
#6 statement doesn't necessarily appear that way on the
expanded-character part of the screen. This is due to the
fact that Modes 1 and 2 can access only half the internal
character set at any given time (see Table 4-5). So if a
PRINT #6 statement refers to some lower-case letters, and
the system is working with the first half of the internal
character set, those characters will be printed to the
expanded-character screen as upper-case characters.
157
o
u
M
U
X
a.
<
(9
T
g
O ^ <N CO
T I I I I II
in CD r- CO OJO'-ojn
o
o
MOU SOIHdVUO
Fig. 4-7. Column/row format for screen Mode 2.
158
Furthermore, the color-register selection depends on
the nature of the characters specified by a print #6
statement:
PRINT #6;upper case will print from color register
PRINT #6;/ower case will print from color register 1
PRINT #6;/nverse upper case will print from color regis-
ter 2
PRINT #6;/nverse lower case will print from color regis-
ter 3
Using the POSITION Statement
The POSITION statement always affects cursor-position
registers COLGRSand ROWCRS; and since these registers
refer to the expanded-character cursor in Modes 1 and 2,
it follows that the POSITION statement works only with
that part of the screen. The text window is not affected by
that statement.
When used with screen Modes 1 and 2, POSITION col,
row statement refers directly to the screens' column/row
format. In that context, the values assigned to col and row
must be within the ranges specified for those screens in
Figs. 4-6 and 4-7. For Mode 1 must be through 19 for
both parameters; and those assigned for Mode 2 must be
through 19 for the col parameter, and through 9 for the
row parameter.
POSITION is most useful for formatting text that is
printed to the expanded-character portion of the screen.
As mentioned earlier, POSITION does not affect the
formatting of text in the text window. It is possible to
simulate a POSITION statement for that portion of the
screen by POKEing col and row values directly into the
text-window cursor registers, TXTCOL and TXTROW. The
general syntax is:
POKE 656,row
POKE 657,co/
where the text-window row values are between and 3,
and the col values are between and 39.
159
Alternative Column/Row Techniques
Plotting expanded-character text to the Mode-1 and -2
screens is not limited to PRINT #6 statements; four state-
ments that are normally regarded as purely graphics
statements— COLOR, PLOT, DRAWTO, and XIO 18— can
be useful, too. PLOT, DRAWTO, and XIO 18 deal with
cursor-position registers OLDROW, OLDCOL, NEWROW
and NEWCOL (see Table 4-6); and in screen Modes 1 and
2, those registers are dedicated to cursor operations in the
expanded-character portions of the screen. Those state-
ments are thus quite useful for expanded-text operations,
but cannot be used for text-window operations.
iOCB Channel 6 must be open in order to use them, but
the execution of a GRAPHICS 1 or GRAPHICS 2 statement
will do that job for you.
Used with the Mode-1 or Mode-2 screen, PLOT co/,row
prints a single character to the designated point on the
expanded character portion of the screen. The character
that is thus printed, and the color register it uses, is deter-
mined by the most recent COLOR statement. Table 4-7
summarizes the character and color register that is speci-
fied by a COLOR statement.
The table shows that each character can be printed from
one of four color registers. Using the normal character set,
for instance, a COLOR 97 will cause a subsequent PLOT
statement to print an upper-case letter A from color regis-
ter 2. But if the alternate internal character set is
selected— by executing a POKE 756,226— the COLOR 97
statement will cause a subsequent PLOT operation to print
a lower-case letter a from color register 2.
In screen Modes 1 and 2, then, the COLOR statement
specifies both the character to be printed and the color
register it is to use. Subsequent PLOT, DRAWTO, and XIO
18 statements will use that information.
160
Table 4-7. Character and Color- Register Codes
for the Color Statement in Screen Modes 1 and 2
Color value and
Register Used
Character Printed |
norm
alt
32
160
128
^
33
1 161
129
1
h
34
2 162
130
\i
1
35
3 163
131
n\
J
36
4 164
132
i A '■
4
37
5 165
133
1 .•' « !
i\
38
6 166
134
y
39
7 167
135
; :
\
40
8 168
136
i (
A
41
9 169
137
i
:
■
42
10 170
138
Ikl
43
11 171
139
. -j-
"■
44
12 172
140
1 *
■ i
45
13 173
141
i
^
46
14 174
142
*
■1^1
47
15 175
143
.••■' i
1
■J
161
Table 4-7— cont. Character and Color-Register Codes
for the Color Statement in Screen Modes 1 and 2
Color value and
Register Used
Character Printed
norm
alt
48
16 176
144
01
+
49
17 177
145
J.
r
50
51
18 178
19 179
146
147
V
— 1
+
52
53
20 180
21 181
148
149
|4|
5
•
m
54
22 182
150
6 ;
1
55
23 183
151
!
/ ;
•' 1
T
1
56
24 184
152
1 :": i
j^
57
25 185
153
"'" 1
1
58
26 186
154
• * ■
r^
59
27 187
155
•> 1
: ?
It
60
28 188
156
■ **.
t
61
29 189
157
::: ;
«
62
63
30 190
31 191
158
159
*-
9
■*
162
Table 4-7— cont. Character and Color- Register Codes
for the Color Statement in Screen Modes 1 and 2
Color value and
Register Used
Character Printed
norm
ait
64
96 192
224
m
!♦!
65
97 193
225
T
•
S
66
98 194
226
51
b
67
99 195
227
c|
c
68
100 196
228
D
d
69
70
101 197
102 198
229
230
lE
e
\j^
f
71
103 199
231
!b!
9
72
104 200
232
; I 1
! t 1
h
73
74
105 201
106 202
233
234
I
i
J
j
75
76
107 203
108 204
235
236
.:
k
1
1
77
78
79
109 205
110 206
111 207
237
238
239
M
J5J
r._
n
n
! •-}
163
Table 4-7— cont. Character and Color-Register Codes
for the Color Statement in Screen Modes 1 and 2
Color value and
Register Used
80
112
208
240
81
113
209
241
82
114
210
242
83
115
211
243
84
116
212
244
85
117
213
245
86
118
214
246
87
119
215
247
88
120
216
248
89
121
217
249
90
122
218
250
91
123
219
251
92
124
220
252
93
125
221
253
94
126
222
254
95
127
223
255
Character Printed
!.i
r\ I
i \
! x
alt
t
!!
K'i
I
X
164
Normally, DRAWTO col,row will draw a line of color
from a PLOT point to the designated column/row coordi-
nate. The last-executed COLOR statement determines the
color of that line. When working with the Mode-1 or
Mode-2 screens, however, the parameter assigned to the
COLOR statement determines the character and color to
be plotted between a PLOT-specified place and the sub-
sequent DRA WTO-specified place.
The XIO 18 statement can fill a section of the screen
with a specified character. For example:
10 GRAPHICS 2
20 PLOT 10,8:DRAWTO 10,0:DRAWT0 0,0:POSITION
0,8
30 POKE 765,193
40 XIO 18,#6,0,0,"S."
Program line 10 sets screen 2 (and opens lOCB #6 for
screen operations), and line 20 defines the outline of a
rectangular field on the screen. Line 30 POKEs the special
COLOR code (Table 4-7) for the desired character, and
line 40 executes the "fill" operation.
Using LOCATE, GET. and PUT in Modes 1 and 2
LOCATE, GET, and PUT also deal with the Mode-1 and -2
screens in a column/row format. Executing a PUT #6,x
plots a character and uses a color register as specified in
Table 4-7. The position is determined by the main print
cursor registers, ROWCRS and COLCRS, and the execu-
tion of the statement advances the cursor position. In this
context, the PUT statement is easier to use than the
COLOR/PLOT combination.
165
The GET statement is the complement of PUT. Rather
than plotting a specified character to the current cursor
location, it returns a code value representing the charac-
ter and color register (as represented in Table 4-7) for any
character that might be printed there. The general form is:
GET #6,numvar
where numvar is a numerical variable that takes on the
special code value.
The LOCATE function is quite similar to GET, but
LOCATE does not operate according to the current cursor
position. In fact, it operates entirely independent of it.
Executing a statement of this general form:
LOCATE col,row,numvar
assigns the code number of any character printed to
Mode-0 location col,row to numerical variable, numvar.
The code format is the one that is shown in Table 4-7.
In screen Modes 1 and 2, the LOCATE statement works
only with the expanded-character portion of the screen.
The Mode-1 and Mode-2 Screen RAM Formats
It is quite often helpful to view the Mode-1 and -2 screens
in terms of the screen RAM addresses and data. Figs. 4-8
and 4-9 show the addressing ranges for each line on the
screen.
This view of the Mode-1 and -2 screens facilitate the use
of POKE and PEEK statements and machine-language rou-
tines for text operations. (The versions in the Appendices
show both decimal and hexadecimal address locations.)
166
g
I- o
S29299992SOOOO
■ r I I T r f
m.
L^
m
tt
rxT
■TT
a> o> o> o>
<o t-- I- m
OO GO 0> O)
o o o o
■? ■^ ■^ Tf
51
ccl
SSSRSSSSS!n§gg§§SS§||
o o ^
OQ CO I
O O I
o-^cMto-<riotDr~.ooa>o-^cMroTincor-.coro(
Fig. 4-8. Screen RAM address format for Mode 1 .
167
POKE and PEEK statements both refer to an address and
a byte of data that is associated with that address. The
address in this case refers to the absolute screen address
locations shown in the table; the data refers to the internal
character codes cited in Table 4-5 as modified by a 2-bit
color-register selection scheme:
POKE addr,16*reg + char
where addr is a RAM address for the expanded-character
portion of the screen, reg is the desired color register, and
char is the internal character code, through 63.
The fact that the internal character codes are limited to
through 63 implies that the statement works with half of
the character set and, further, it cannot deal with inverse
characters. Executing a POKE 756,226 sets up the alternate
half of the character set, and executing a POKE 756,224
returns the system to the normal character set.
In this context, the following sort of PEEK statement
returns the combined internal-code value and color regis-
ter of the character residing at the specified address:
PEEK(addr)
It is possible to do direct PEEK and POKE operations to
the text-window portions of the screen. Tables 4-8 and 4-9
indicate the RAM addressing range for that part of the
screen. The data refers to the ATASCII character codes in
the same way it does for Mode-0 screen operations.
Full-Screen Formats
Adding 16 to the graphics screen number brings up the
screen without a text window. Executing a GRAPHICS 17,
for example, brings up a full-screen version of Mode-1.
Several seconds after the conclusion of a program that
uses the full screen, the system automatically reverts to its
split-screen version.
168
5
HO
in
1
o
I
i
1
g
1
g
1
g
1
T
0>
1
2i
CO
1
0> O) O) o> o>
in CO 1^ ^ lo
o o o o o
T TTTT
o
1
o
00
in
o
1
o
g
1
o
1
^
1
8
1
o
1 I 1 1 1
o o o o o
Tf O -^ OO CM
r*«- oo CO CO O}
o o o o o
■* i-<s- Tf Tf -^a-
O o
ccl
0> O T- CM CO
Fig. 4-9. Screen RAM address format for Mode 2.
169
Table 4-8. Color Register Sequences
and Screen Data Bytes for 4-Pixel/Bit Screens
(Modes 3.5.7. and Their Variations)
Color Register
(Left — Right)
Data
Byte
Color Register
(Left - Right)
Data
Byte
1
2
3
1
2
3
2
2
2
2
1
2
3
32
33
34
35
1
1
1
1
1
2
3
4
5
6
7
2 1
2 1
2 1
2 1
1
2
3
36
37
38
39
2
2
2
2
1
2
3
8
9
10
11
2 2
2 2
2 2
2 2
1
2
3
40
41
42
43
3
3
3
3
1
2
3
12
13
14
15
2 3
2 3
2 3
2 3
1
2
3
44
45
46
47
1
1
1
1
1
2
3
16
17
18
19
3
3
3
3
1
2
3
48
49
50
51
1 1
1 1
1 1
1 1
1
2
3
20
21
22
23
3 1
3 1
3 1
3 1
1
2
3
52
53
54
55
1 2
1 2
1 2
1 2
1
2
3
24
25
26
27
3 2
3 2
3 2
3 2
1
2
3
56
57
58
59
1 3
1 3
1 3
1 3
1
2
3
28
29
30
31
3 3
3 3
3 3
3 3
1
2
3
60
61
62
63
170
Table 4-8— cont. Color Register Sequences
and Screen Data Bytes for 4-Pixel/Bit Screens
(Modes 3,5,7, and Their Variations)
Color Register
(Left — Right)
Data
Byte
Color Register
(Left - Right)
Data
Byte
1
1
1
1
1
2
3
64
65
66
67
1 2
1 2
1 2
1 2
1
2
3
96
97
98
99
1 1
1 1
1 1
1 1
1
2
3
68
69
70
71
1 2 1
1 2 1
1 2 1
1 2 1
1
2
3
100
101
102
103
1 2
1 2
1 2
1 2
1
2
3
72
73
74
75
1 2 2
1 2 2
1 2 2
1 2 2
1
2
3
104
105
106
107
1 3
1 3
1 3
1 3
1
2
3
76
77
78
79
1 2 3
1 2 3
1 2 3
1 2 3
1
2
3
108
109
110
111
1 1
1 1
1 1
1 1
1
2
3
80
81
82
83
1 3
1 3
1 3
1 3
1
2
3
112
113
114
115
1 1 1
1 1 1
1 1 1
1 1 1
1
2
3
84
85
86
87
1 3 1
1 3 1
1 3 1
1 3 1
1
2
3
116
117
118
119
1 1 2
1 1 2
1 1 2
1 1 2
1
2
3
88
89
90
91
1 3 2
1 3 2
1 3 2
1 3 2
1
2
3
120
121
122
123
1 1 3
1 1 3
1 1 3
1 1 3
1
2
3
92
93
94
95
1 3 3
1 3 3
1 3 3
1 3 3
1
2
3
124
125
126
127
171
Table 4-8— cont. Color Register Sequences
and Screen Data Bytes for 4-Pixel/Bit Screens
(Modes 3,5.7, and Their Variations)
Color
Registei
Data
Color
Register
Data
(Left-
- Right)
Byte
(Left
- Right)
Byte
2
128
2
2
160
2
1
129
2
2
1
161
2
2
130
2
2
2
162
2
3
131
2
2
3
163
2
1
132
2
2
1
164
2
1
1
133
2
2
1 1
165
2
1
2
134
2
2
1 2
166
2
1
3
135
2
2
1 3
167
2
2
136
2
2
2
168
2
2
1
137
2
2
2 1
169
2
2
2
138
2
2
2 2
170
2
2
3
139
2
2
2 3
171
2
3
140
2
2
3
172
2
3
1
141
2
2
3 1
173
2
3
2
142
2
2
3 2
174
2
3
3
143
2
2
3 3
175
2
144
2
3
176
2
1
145
2
3
1
177
2
2
146
2
3
2
178
2
3
147
2
3
3
179
2
1
148
2
3
1
180
2
1
1
149
2
3
1 1
181
2
1
2
150
2
3
1 2
182
2
1
3
151
2
3
1 3
183
2
2
152
2
3
2
184
2
2
1
153
2
3
2 1
185
2
2
2
154
2
3
2 2
186
2
2
3
155
2
3
2 3
187
2
3
156
2
3
3
188
2
3
1
157
2
3
3 1
189
2
3
2
158
2
3
3 2
190
2
3
3
159
2
3
3 3
191
172
Table 4-8— cont. Color Register Sequences
and Screen Data Bytes for 4-Pixel/Bit Screens
(Modes 3,5,7. and Their Variations)
Color Register
(Left — Right)
Data
Byte
Color Register
(Left - Right)
Data
Byte
3
3
3
3
1
2
3
192
193
194
195
3
3
3
3
2
2
2
2
1
2
3
224
225
226
227
3
3
3
3
1
1
1
1
1
2
3
196
197
198
199
3
3
3
3
2 1
2 1
2 1
2 1
1
2
3
228
229
230
231
3
3
3
3
2
2
2
2
1
2
3
200
201
202
203
3
3
3
3
2 2
2 2
2 2
2 2
1
2
3
232
233
234
235
3
3
3
3
3
3
3
3
1
2
3
204
205
206
207
3
3
3
3
2 3
2 3
2 3
2 3
1
2
3
236
237
238
239
3
3
3
3
1
1
1
1
1
2
3
208
209
210
211
3
3
3
3
3
3
3
3
1
2
3
240
241
242
243
3
3
3
3
1 1
1 1
1 1
1 1
1
2
3
212
213
214
215
3
3
3
3
3 1
3 1
3 1
3 1
1
2
3
244
245
246
247
3
3
3
3
1 2
1 2
1 2
1 2
1
2
3
216
217
218
219
3
3
3
3
3 2
3 2
3 2
3 2
1
2
3
248
249
250
251
3
3
3
3
1 3
1 3
1 3
1 3
1
2
3
220
221
222
223
3
3
3
3
3 3
3 3
3 3
3 3
1
2
3
252
253
254
255
173
Table 4-9. Starting and Ending Addresses
for Each Row of the Mode-5 Screen RAM
Row
Decimal
Row
Decimal
Start
End
Start
End
Row
39840
39859
Row 24
40320
40339
Row 1
39860
39879
Row 25
40340
40359
Row 2
39880
39899
Row 26
40360
40379
Row 3
39900
39919
Row 27
40380
40399
Row 4
39920
39939
Row 28
40400
40419
Row 5
39940
39959
Row 29
40420
40439
Row 6
39960
39979
Row 30
40440
40459
Row 7
39980
39999
Row 31
40460
40479
Row 8
40000
40019
Row 32
40480
40499
Row 9
40020
40039
Row 33
40500
40519
Row 10
40040
40059
Row 34
40520
40539
Row 11
40060
40079
Row 35
40540
40559
Row 12
40080
40099
Row 36
40560
40579
Row 13
40100
40119
Row 37
40580
40599
Row 14
40120
40139
Row 38
40600
40619
Row 15
40140
40159
Row 39
40620
40639
Row 16
40160
40179
Row 17
40180
40199
Text window begin
s here
Row 18
40200
40219
Row 19
40220
40239
Row
40800
40839
Row 20
40240
40259
Row 1
40840
40879
Row 21
40260
40279
Row 2
40880
40919
Row 22
40280
40299
Row 3
40920
40959
Row 23
40300
40319
Figs. 4-10 and 4-11 show the column/row formats for
full-screen Modes 17 and 18, respectively. Those versions
offer more rows of expanded-character space than is
available with their split-screen counterparts.
Figs. 4-12 and 4-13 show full-screen Modes 17 and 18 in
a screen RAM address format— one more suitable for
PEEK, POKE, and machine-language operations.
174
n ^-
mOU SOIHdVUO
Fig. 4-10. Column/row format for Mode 17 (full-screen version of
IVIodel).
175
ft_
00_
h-_
<o_
lf)_
■<r_
n_
OJ_
--
o_
a> —
00 —
1
co-
in—
■«■ —
CO —
C\J —
—
o —
/
1 i I I I r
O '- CM CO TT in CD
I i I r
00 Ol o 1-
mOU SOIHdVUO
Fig. 4-11. Column/row format for Mode 18 (full-screen version of
Mode 2).
176
coinr^o>-^coir)p^o>ir-coir)r-o)i-coif)h-0)i'-comr^o>
OOOOQOOOOOOOOOOOOOOOOOOO)
^^^^^^^^^ ^'^'^ ^'^■^^^ ^^^^^^^
I I I I I I I I I I I I I I
rr
m
Tl
'OOOOOOOO o oooo<
l-^CDOOOCsl^tDOOO C>J-^<D0O<
'OOOOOOOOO OOOOi
■ -^ ^ ^ -^ ^ '
TT
o o o o
_ CM ^ (D 00
1^ N. 1^ h- P^
O O O O O
'■^■^ ■^■^■^•^^^■^^^^^■^t-'t-^
o
irl
T-ojco-^m<D^-cooiO'-cgco^incDh-ooo>0'-CMco
Fig. 4-12. Screen RAM address format for Mode 17 (full-screen
version of Mode 1 ).
177
0> O) O)
r- O) 1-
in in o
goo
O)
O)
r^
<o
o
s ?
T^-
I
p
s
K
S
r^
y
O
o
o
r_I
1 r
51
I ^1 I — r
o o o o
CM -^ (D S
r; 1^ r^ ri.
o o o o
Fig. 4-13. Screen RAM address format for Mode 18 (full-screen
version of Mode 2).
178
CUSTOM CHARACTERS SETS FOR MODES 1
AND 2
The foregoing discussions make numerous reference to
the ATARI'S ROM-based character set. Recall that the
Mode-0 screen can access all 128 characters with no spe-
cial programming, and that screen modes 1 and 2 can
access it 64 characters at a time by POKEing appropriate
values into register address 756.
It is possible, however, to construct custom character
sets, load them into some unused RAM area, and then
substitute them for ATARI'S ROM-based set.
The character set must be bit mapped, with each charac-
ter bemg 8 bytes long. Fig. 4-14 illustrates the procedure
for generatmg the bit maps for four custom characters—
the first four letters of the Hebrew alphabet, in this case.
Starting with a sheet of ordinary graph paper, construct
the desired characters within an 8 x 8 character window
Then translate each square into a or 1 binary bit; specify
a 1 where a pixel of light is to be plotted, and a where the
background color is to appear. Finally, translate the result-
ing 8 bytes into their decimal counterparts. The series of
decimal numbers are those that are to be inserted into the
RAM area where your custom character set is to appear.
Actually, there will be five characters in this example
because the first character ought to be a blank— eight
decimal zeros. The reason is that the computer will use the
first character in the character set as the one for plotting
the background; and you normally want the background
to be blank.
179
1 1
1
1 1
1
78
36
SO
76
36
64
60
2
16
2
124
64
60
2
2
2
124
64
48
16
16
16
104
Fig. 4-14. Development of the bit map for several Hebrew characters
to be used in a custom character set. The set must begin
with an 8 X 8 bit map that is filled with zeros if the screen
background is to be blank.
One good place to insert a custom, bit-mapped charac-
ter set is at address 32768. (The standard ATARI character
set begins at address 57344, or hexadecimal $E000; but you
cannot use that area because it is a ROM area.)
180
Here is a routine that will define the blank character and
the four Hebrew characters, and insert them into RAM
space at address 32768 ($8000):
10 DATA 0,0,0,0
20 DATA 0,78,36,50,76,36,98,0
30 DATA 0,64, 60, 2, 18, 2, 124,0
40 DATA 0,64,60,2,2,2,124,0
50 DATA 0,64,48,16,16,16,104,0
100 FOR N = 0TO39
110 READ A:POKE 32768+N,A
120 NEXTN
The DATA in lines 10 through 50 define the blank space
and four Hebrew characters. Lines 100 through 120 then
READ the data and POKE it into 40 successive RAM loca-
tions, beginning from address 32768. The custom charac-
ter set is useless, however, unless you can print it to the
screen.
A routine that lets you print the custom characters must
begin by informing the system where the character set
begins; and that is a matter of POKEing the MSB of the
starting address into address 756 — the same location that is
used for specifying the first or second half of the standard
character set.
The custom character set in this example begins at
address 32768, or $8000. The hexadecimal version of the
MSB is $80, and that translates into decimal 128. So in this
instance, you specify the location of the custom character
set with this sort of statement:
POKE 756,128
From that point on, the system will literally substitute your
character set for the normal one.
181
Assuming, then, that you have executed a routine that
loads the custom character set at address 32768, the fol-
lowing routine will print the blank character and four
Hebrew characters to the Mode-0 screen:
200 GRAPHICS
210 SETCOLOR 1,0,14
220 POKE 756,128
230 FOR N = 0TO4
240 POKE 40500+N,N
250 NEXT N
All printing and expanded-character operations described
for the ROM-based character set apply to custom charac-
ter sets. The custom character set can have up to 128 dif-
ferent characters in it, and the system will access them in
the same sequence that it accesses the ROM-based set. In
Modes 1 and 2, you can access no more than 64 characters
at a time; and whenever there is a need to access a differ-
ent part of any character set, simply POKE the decimal
version of the MSB of the starting address to location 756
(that, incidentally, allows you to mix custom and normal
characters). And you can display inverse versions of a cus-
tom character set in screen Mode by adding 128 to the
usual internal character code number; likewise, you can
use different color registers in Modes 1 and 2 by using the
COLOR statement.
In short, a custom character set can be treated exactly
like the normal ROM-based character set. The only diffi-
cult parts are designing and loading the custom character
set into the system.
THE FOUR-COLOR MODES: 3, 5, AND 7
Graphics Modes 3, 5, 7, and their variations have a great
deal in common, particularly with regard to the organiza-
tion of the color registers and the screen data. The most
obvious differences concern the size and number of pixels
they use.
182
Working With the Color Registers
Fig. 4-15 shows the organization of the color registers for
graphics Modes 3, 5, and 7. The text window uses the usual
Mode-0 register format: the luminance of the characters is
determined by register 1, the character hue and text-
window background color is determined by register 2,
and the text-window color is carried in register 4.
TEXT WINDOW
MODES
3,5,7
NOT USED
LUMINANCE OF
CHARACTER
CHARACTER HUE
AND BACKGROUND
COLOR
NOT USED
BORDER
COLOR
REGISTER
ADDRESS 708
COLOR 1
REGISTER 1
ADDRESS 709
COLOR 2
REGISTER 2
ADDRESS 710
COLOR 3
REGISTER 3
ADDRESS 711
NOT USED
REGISTER 4
ADDRESS 712
BACKGROUND
COLOR
Fig. 4-15. Color register organization for IVIodes 3, 5, 7, and their
variations.
The color-register diagram shows that the graphics and
text window share three of the four color registers used in
these graphics modes. For that reason, there is bound to
be some interaction between the color environments for
the graphics and text-window portions of the screen.
The colors assigned to any of these registers can be
determined by executing the SETCOLOR reg,hue,lum
statement, where reg refers to the standard color-register
numbering format, and hue and lum are determined from
Tables 4-2 and 4-3. It is also possible to specify the colors
by executing POKE addr,color statements, where addr is
the RAM address of the register and color is the overall
color designation that is determined by the formula:
color = 1 6*hue + lum
183
It is very important, however, to understand that the
COLOR statement— the BASIC statement that refers some
subsequent plotting operation to a color register — does
not refer to the same register-numbering format as the
SETCOLOR statement. The general COLOR num refers to
color-register num in this fashion:
COLOR — Register 4 (RAM address 712)
COLOR 1 — Register (RAM address 708)
COLOR 2 — Register 1 (RAM address 709)
COLOR 3 — Register 2 (RAM address 710)
Column/Row Screen Formats and Graphics Operations
Figs. 4-16, 4-17, and 4-18 show the column/row format for
screen Modes 3, 5, and 7, respectively. Notice that all of
them include a 40-column, 4-row text window.
It is important to bear in mind the column/row sizes
when using a good many of the BASIC graphics statements —
attempting to work outside the column/row areas will
bring up error messages.
The following BASIC graphics statements apply directly
to these column/row formats:
POSITION col. row
PLOT col, row
DRAWTO col, row
LOCATE col, row, x
And these BASIC statements refer to the column/row
formats in a less direct way — through the cursor-position
registers (see Table 4-6):
PUT #6, reg
GET #6, X
PRINT #6;
184
g
1-9
"I
s-
s-
CO"
f§-
S-
?.-
s-
?l-
CO"
s-
^-
s-
CM
CO
CM
co_
CM
CM
CM"
Si-
o>_
00_
r-_
CD_
ID-
'^_
CO-
CM.
^-
o_
O)-
00-
r»--
CD-
in-
■^-
co-
CM-
1--
o-
J 1 1
1
/
o
1
1
CM
1
CO
1
1
1
CO
1
1
CO
1
CJ)
1
o
j_
1
CM
1
CO
1
1
in
1
CD
1
1
00
1
CJ>
1
o
1
1
CM
1
/WOU SOIHdVUO
Fig. 4-1 6. Column/row format for the Mode-3 screen.
185
I- o
III '-'
o
o
CO
u
I
a.
<
a
o-rr~T —
/ o in
fflffiffi
O 1- CM CO
O
u
MOU SOIHdVUO
Fig. 4-17. Column/row format for the Mode-5 screen.
186
5
5
o
o
CO
y
X
a.
<
EC
(9
O
O
T
O ^ CM CO
mOU SOIHdVUO
Fig. 4-18. Column/row format for the Mode-7 screen.
187
As in the case of the expanded-character modes, the
PRINT statement refers to text-window coordinates as
defined in register TXTROW and TXTCOL, and the XI0 18
function does a graphics fill operation when applied
according to the following algorithm:
1 PLOT the lower right-hand pixel of the figure.
2. DRAWTO the upper right-hand pixel location.
3. DRAWTO the upper left-hand pixel location.
4. POSITION the lower right-hand pixel location.
5. POKE the color register to be used to address 765.
6. Execute XIO 18,#6,0,0,"S:".
Figs. 4-19, 4-20, and 4-21 show the full-screen versions of
the 4-color modes that are called by graphics Modes 19,
21, and 23. Doing away with the text window adds more
rows of graphics to the bottom of the screen.
The Screen RAM Address Formats and Operations
Fig. 4-22 shows the RAM addressing format for the Mode-
3 screen, it is particularly important to notice that this
40-column screen uses 10 consecutive RAM address loca-
tions per row. The reason for this apparent discrepancy is
that all 4-color modes use a single byte of data to specify
the color registers for four consecutive column locations.
It is thus possible to plot 800 different pixels (column/row
format) with just 200 screen RAM locations (screen RAM
format).
One byte of screen data covers four consecutive, hori-
zontal pixel, or PLOT, locations on the screen; and the
information carried within that byte specifies the color
registers that are to be used for plotting its four graphics.
Consider a general POKE statement of this form:
POKE acldr,data
In terms of the Mode-3 screen RAM format, addr referen-
ces one of 200 groups of 4 pixels each. The data then sets a
color for plotting each of those 4 pixels. Fig. 4-23 shows
how the data byte is organized.
188
mOU SOIHdVUO
Fig. 4-19. Column/row format for the Mode-1 9 screen.
189
o
u
M
O
X
Q.
<
a
8-:
o
t- CM
T
o
MOU SOIHdVUO
Fig. 4-20. Column/row format for the Mode-21 screen.
190
o
o
(/>
o
I
a.
<
DC
a
MOU SOIHdVUO
Fig. 4-21 . Column/row format for the Mode-23 screen.
191
g
I- o
IT
C
ir
o
in
J.
a
a
IT
c
-J.
S
CD CT
y- CS
1 1
1 1
s
CO
1
a
1
1
1
i
1
s
1
05
1
o
1
o
O ^ O) O} O) O)
^ 1/) CO N- 1- in
r^ h- GO 00 O} O)
g g o o o o
■^ ■» Tf ■* Tf ■»
J j 1 1 1 1
_
-
_
-
_
^
^
_
~
_
"
" ■
~
-
^
^
~
_
"
"
" "
-
_
-
^
~
^
^
™ ■
~
_
~
~
^
^
"
" "
"
-
B,
^
^
"
'
_
^
" ■
_
-
_
K
^
^
^
^
""
" ■
-
^
^
"
™ ■
_
_
_
^
_
^
^
■ ■
_
_
^
_
J
"
■ ■
_.
,1111
1
O
CD
in
O
•^ (.
n i
::> c
■a- ■
<*
1
3
^
3
^
1
1
§
1
o c
^ I
X) c
o c
'a- -
o c
D (
D C
sj- -
1
1
ID
1
=3-
1
1
^ r
■3-
1 1
^ lf>
3 o
1 "T"
1 ]
X> <N
3 O
■a- -"d-
Fig. 4-22. Screen RAM address format for the Mode-3 screen.
192
SCREEN DATA BYTE
MSB LSB
D7 D6 D5 D4 D3 D2 D1 DO
LEFT
PIXEL
PIXEL PIXEL PIXEL
1 2 3
RIGHT
PIXEL-BIT
VALUES
EQUIVALENT
COLOR-SELECT
VALUE
COLOR
REGISTER
USED
00
01
10
11
COLOR
COLOR 1
COLOR 2
COLOR 3
4
1
2
Fig. 4-23. Organization of screen data bytes for Ixodes 3, 5, 7, and
their variations.
The data byte is divided into 4 pairs of bits. The two
higher-order bits determine the color that is plotted by
the leftmost pixel, bits D5 and D4 fix the color for the
second pixel, bits D3 and D2 determine the color for the
third pixel, and the two lower-order bytes determine the
color for the rightmost pixel in the group.
In a manner of speaking, the addr portion of a POKE
statement determines the location of the plotting opera-
tion within four pixels; and then the data portion of both
fine-tunes the pixel positions and determines their color.
Now recall the COLOR num statement as it applies to
the 4-color graphics modes. The num term can be a posi-
tive integer value between and 3, inclusively; thereby
making it possible to specify colors from one of four dif-
ferent color registers. The four num values for a COLOR
statement relate directly to the values assigned to the data
portion of a POKE statement.
The figure shows a 2-bit binary equivalent for each
COLOR statement that can be used in 4-color graphics. If
a pair of bytes assigned to one pixel happens to be 00, a
POKE statement will plot that pixel position with a color
that is equivalent to that of doing a COLOR statement.
Suppose, then, that you POKE this data byte into some
Mode-3 screen address:
10 11 00 01
193
The leftmost pixel will be plotted with a color that is equi-
valent to doing a COLOR 2 statement (a color from regis-
ter 1). The second pixel will take a color that is equivalent
to COLOR 3; the third will be equivalent to doing COLOR
0; and the rightmost pixel will be plotted with a color that
is equivalent to doing a COLOR 1 statement.
The following program plots four consecutive pixels at a
single RAM address:
10 GRAPHICS 3
20 POKE 40664,109
The POKE address points to the middle of the graphics
screen; and if you break down the data — decimal 109 —
into its binary counterpart, you will find it is:
01 10 11 01
And that suggests this COLOR sequence:
COLOR 1
COLOR 2
COLOR 3
COLOR 1
Each byte of POKE data refers to four consecutive,
horizontal pixel locations and four color registers. I have
just described how the data byte is organized, but it is
clearly a troublesome procedure to implement. On the
other hand, graphics programs using POKE statements can
have the same level of resolution, but switch around the
color-register designations, with far fewer programming
statements than the more conventional COLOR/PLOT
combinations.
194
Table 4-8 goes a long way toward simplifying the proce-
dure for determining the value of a desired POKE byte.
The table indicates four different COLOR-oriented num
values that are fit into a data byte and plot to the screen in
a left-to-right fashion. Thus, if you want to POKE four
consecutive pixels that use the equivalent of COLOR 1,
COLOR 3, COLOR 3, COLOR 2, simply find the sequence
1 3 3 2 in the table. The decimal data byte associated with
that combination— 126 in this case— is the corresponding
data for the POKE statement.
The procedure applies equally well to all 4-color graph-
ics screen formats.
Fig. 4-24 shows the screen RAM organization for the
Mode-5 screen, and Table 4-9 shows the starting and end-
ing addresses for each row, including those used for the
text-window portion of the screen. Fig. 4-25 and Table
4-10 show the same information as it relates to the Mode-7
screen.
Figs. 4-26 through 4-28, and Tables 4-11 through 4-13
show the RAM screen organization and corresponding
start-and-end addresses for each row of screen Modes 19,
21, and 23.
TWO-COLOR MODES 4 AND 6
Screen Modes 4 and 6 are 2-color, high-resolution graph-
ics screens. They use a color-register scheme and data-
byte format that is different from the 4-color screens.
195
I- o
-39859
_40639
-40839
CO
1
§
1
a
in
1
__. ._ _
-J- _ -
± _ . ------ -----
39840-
40620-
40800-
1
o
-^
CO
o
O
00
§
1
o
CVJ
§
Fig. 4-24. Screen RAM address format for the Mode-5 screen. See
detailed listing of the addresses in Table 4-9.
196
5
I- o
xq
36999
40159
-40839
-40879
-40919
1
<*
1
t-
m
cc
0.
U)
lU
a.
-1
z
o
N
o
X
«
36960
40120
1
1
o
oo
1
00
O
1
Fig. 4-25. Screen RAM address format for the Mode-7 screen. See a
detailed listing of the addresses In Table 4-10.
197
Table 4-10. Starting and Ending Addresses
for Each Row of the Mode-7 Screen RAM
Addresses
Addresses 1
Row
Row
Start
End
Start
End
Row 1
m
37000
i!!ff
37039
111
Row 45
38760
iii
38799
Row 2
37040
37079
Row 46
38800
38839
Row 3
37080
37119
Row 47
38840
38879
Row 4
37120
37159
Row 48
38880
38919
Row 5
37160
37199
Row 49
38920
38959
Row 6
37200
37239
Row 50
38960
38999
Row 7
37240
37279
Row 51
39000
39039
Row 8
37280
37319
Row 52
39040
39079
Row 9
37320
37359
Row 53
39080
39119
Row 10
37360
37399
Row 54
39120
39159
Row 11
37400
37439
Row 55
39160
39199
Row 12
37440
37479
Row 56
39200
39239
Row 13
37480
37519
Row 57
39240
39279
Row 14
37520
37559
Row 58
39280
39319
Row 15
37560
37599
Row 59
39320
39359
Row 16
37600
37639
Row 60
39360
39399
Row 17
37640
37679
Row 61
39400
39439
Row 18
37680
37719
Row 62
39440
39479
Row 19
37720
37759
Row 63
39480
39519
Row 20
37760
37799
Row 64
39520
39559
Row 21
37800
37839
Row 65
39560
39599
Row 22
37840
37879
Row 66
39600
39639
Row 23
37880
37919
Row 67
39640
39679
Row 24
37920
37959
Row 68
39680
39719
Row 25
37960
37999
Row 69
39720
39759
Row 26
38000
38039
Row 70
39760
39799
Row 27
38040
38079
Row 71
39800
39839
Row 28
38080
38119
Row 72
39840
39879
Row 29
38120
38159
Row 73
39880
39919
Row 30
38160
38199
Row 74
39920
39959
Row 31
38200
38239
Row 75
39960
39999
Row 32
38240
38279
Row 76
40000
40039
Row 33
38280
38319
Row 77
40040
40079
Row 34
38320
38359
Row 78
40080
40119
Row 35
38360
38399
Row 79
40120
40159
Row 36
Row 37
38400
38440
38439
38479
Text w
ndow begin
s here
Row 38
Row 39
38480
38520
38519
38559
Row
40800
40839
Row 40
38560
38599
Row 1
40840
40879
Row 41
38600
38639
Row 2
40880
40919
Row 42
38640
38679
Row 3
40920
40959
Row 43
38680
38719
198
(Dr*cocnoi-cMcOTt-m<Dh*flOO)0^-cMco ^mtor-ooo)
ooooooooooo OOO QOOO oooooo
oo
CO f^
lo in
o o
I I I I I I I i I I I I I I I I I I I I ) )
OOOOOOOOOOOO OOOOOOOOOQ
coaiO^<NcoTrmcDN-coo>o^cMco ^mtoh-oooi
iOincocDcDcocDcD(DtDcDiDr^r^^-r^ h-r**r«-r*-p*-(^
OOOOOOOOOOO
— — — — TT-'a-'^^-^ -* —
(■«w !■». i~. !-». |-«. I— i-». i^- 1-^ I —
oooo oooooo
Fig. 4-26. Screen RAM addressformatforthe Mode-19screen. Seea
detailed listing of the addresses in Table 4-11.
199
>■
m
oc
UJ
Q.
° 1 1 1 1 1 1 1 1 1 1 I4T
iiiiiiiiiiiiiiiiiiiiiiiiiiiiii
iiiiiiiiiiiiiiiiiii
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■1
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■1
■■■■■■■■■■■■■■■■■■a
■■■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■1
{■■■■■■■■■■■■■■■■■B
iiiiuiiiiiiiaiiiiiiiiiiiiiiii
iiiiiiiiiiiiiiiiiii
!■■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■i
■■■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■1
»■■■■■■■■■■■■■■■■■
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a
ff+TT
-H-+-l--|--H--|-H--(--l-++^^
........»......»...........»■■■■■■■■■■».■■..
T
r
X "
. . _
::: ±
±
— i
— j.
1
1
Fig. 4-27. Screen RAM acldressformatfortheMode-21 screen. Seea
detailed listing of the addresses in Table 4-12.
200
o
>-
m
cc
UJ
a.
-I
UJ
X
a
z
o
N
cc
o
°1
0)l — h
Fig. 4-28. ScreenRAMaddressformatfortheMode-23screen. Seea
detailed listing of the addresses in Table 4-13.
201
Working With the Color Registers for Screen Modes 4
and 6
Fig. 4-29 shows the organization of the color registers for
screen Modes 4, 6 and their variations. The text window
uses the usually Mode-0 register format: the luminance of
the characters is determined by register 1, the character
hue and text-window background color is determined by
register 2, and the text-window color is carried in regis-
ter 4.
Unlike the 4-color screens, there is no troublesome
sharing of color registers between the graphics portion of
the screen and the text window. The graphics and text-
window portions do share register 4 (graphics COLOR 0),
but register (graphics COLOR 1) is now for the exclusive
use of graphics operations.
You can set the color for register in one of two ways:
SETCOLOR O.hue.lum
or
POKE 708, 16*/um + hue
where the hue and lum values can be determined from
Tables 4-2 and 4-3, respectively. In either case, you can
then access that register by doing a COLOR 1 statement.
The system forces you to use color register 4 for the
graphics background. A SETCOLOR statement will refer to
it as register 4, but a COLOR statement will refer to it in
terms of COLOR 0. Although it is dedicated to the back-
ground color, color register 4 can be useful for deleting
selected portions of previously drawn graphics.
202
Table 4-1 1 . Starting and Ending Addresses
for Each Row of the IVIode-l 9 Screen RAIVI
Row
Address
Start
End
Row
40560
40569
Row 1
40570
40579
Row 2
40580
40589
Row 3
40590
40599
Row 4
40600
40609
Row 5
40610
40619
Row 6
40620
40629
Row 7
40630
40639
Row 8
40640
40649
Row 9
40650
40659
Row 10
40660
40669
Row 11
40670
40679
Row 12
40680
40689
Row 13
40690
40699
Row 14
40700
40709
Row 15
40710
40719
Row 16
40720
40729
Row 17
40730
40739
Row 18
40740
40749
Row 19
40750
40759
Row 20
40760
40769
Row 21
40770
40779
Row 22
40780
40789
Row 23
40790
40799
Column/Row Screen
Modes 4 and 6
Formats and Operations for
Figs. 4-30 and 4-31 show the column/row screen formats
for graphics Modes 4 and 6. These formats are most
appropriate when using PLOT, POSITION, DRAWTO, and
LOCATE statements; and they are, incidentally, important
when working with LOCATE, PUT #6, GET #6, XIO 18, and
PRINT #6 statements. As in the case of the 4-color, split-
screen modes, these feature a 40-column, 4-row text win-
dow that can be directly accessed with norma! PRINT
statements.
203
Table 4-12. Starting and Ending Addresses
for Each Row of the Mode-21 Screen RAM
Row
Decimal
Row
Decimal
Start
End
Start
End
Row
39840
39859
Row 24
40320
40339
Row 1
39860
39879
Row 25
40340
40359
Row 2
39880
39899
Row 26
40360
40379
Row 3
39900
39919
Row 27
40380
40399
Row 4
39920
39939
Row 28
40400
40419
Row 5
39940
39959
Row 29
40420
40439
Row 6
39960
39979
Row 30
40440
40459
Row 7
39980
39999
Row 31
40460
40479
Row 8
40000
40019
Row 32
40480
40499
Row 9
40020
40039
Row 33
40500
40519
Row 10
40040
40059
Row 34
40520
40539
Row 11
40060
40079
Row 35
40540
40559
Row 12
40080
40099
Row 36
40560
40579
Row 13
40100
40119
Row 37
40580
40599
Row 14
40120
40139
Row 38
40600
40619
Row 15
40140
40159
Row 39
40620
40639
Row 16
40160
40179
Row 40
40640
40659
Row 17
40180
40199
Row 41
40660
40679
Row 18
40200
40219
Row 42
40680
40699
Row 19
40220
40239
Row 43
40700
40719
Row 20
40240
40259
Row 44
40720
40739
Row 21
40260
40279
Row 45
40740
40759
Row 22
40280
40299
Row 46
40760
40779
Row 23
40300
40319
Row 47
40780
40799
204
Table 4-13. Starting and Ending Addresses
for Each Row of the Mode-23 Screen RAM
Row
Addresses
Row
Addresses
Start
End
Start
End
Row
36960
36999
Row 36
38400
38439
Row 1
37000
37039
Row 37
38440
38479
Row 2
37040
37079
Row 38
38480
38519
Row 3
37080
37119
Row 39
38520
38559
Row 4
37120
37159
Row 40
38560
38599
Row 5
37160
37199
Row 41
38600
38639
Row 6
37200
37239
Row 42
38640
38679
Row 7
37240
37279
Row 43
38680
38719
Row 8
37280
37319
Row 44
38720
38759
Row 9
37320
37359
Row 45
38760
38799
Row 10
37360
37399
Row 46
38800
38839
Row 11
37400
37439
Row 47
38840
38879
Row 12
37440
37479
Row 48
38880
38919
Row 13
37480
37519
Row 49
38920
38959
Row 14
37520
37559
Row 50
38960
38999
Row 15
37560
37599
Row 51
39000
39039
Row 16
37600
37639
Row 52
39040
39079
Row 17
37640
37679
Row 53
39080
39119
Row 18
37680
37719
Row 54
39120
39159
Row 19
37720
37759
Row 55
39160
39199
Row 20
37760
37799
Row 56
39200
39239
Row 21
37800
R7839
Row 57
39240
39279
Row 22
37840
37879
Row 58
39280
39319
Row 23
37880
37919
Row 59
39320
39359
Row 24
37920
37959
Row 60
39360
39399
Row 25
37960
37999
Row 61
39400
39439
Row 26
38000
38039
Row 62
39440
39479
Row 27
38040
38079
Row 63
39480
39519
Row 28
38080
38119
Row 64
39520
39559
Row 29
38120
38159
Row 65
39560
39599
Row 30
38160
38199
Row 66
39600
39639
Row 31
38200
38239
Row 67
39640
39679
Row 32
38240
38279
Row 68
39680
39719
Row 33
38280
38319
Row 69
39720
39759
Row 34
38320
38359
Row 70
39760
39799
Row 35
38360
38399
Row 71
39800
39839
205
Table 4-13— cont. Starting and Ending Addresses
for Each Row of the Mode-23 Screen RAM
Row
Addresses
Row
Addresses
Start
End
Start
End
Row 72
Row 73
Row 74
Row 75
Row 76
Row 77
Row 78
Row 79
Row 80
Row 81
Row 82
Row 83
39840
39880
39920
39960
40000
40040
40080
40120
40160
40200
40240
40280
39879
39919
39959
39999
40039
40079
40119
40159
40199
40239
40279
40319
Row 84
Row 85
Row 86
Row 87
Row 88
Row 89
Row 90
Row 91
Row 92
Row 93
Row 94
Row 95
40320
40360
40400
40440
40480
40520
40560
40600
40640
40680
40720
40760
40359
40399
40439
40479
40519
40559
40599
40639
40679
40719
40759
40799
TEXT WINDOW
NOT USED
LUMINANCE OF
CHARACTER
CHARACTER HUE
AND BACKGROUND
COLOR
NOT USED
BORDER
COLOR
MODES
4&6
REGISTER
ADDRESS 708
COLOR 1
REGISTER 1
ADDRESS 709
NOT USED
REGISTER 2
ADDRESS 710
NOT USED
REGISTER 3
ADDRESS 711
NOT USED
REGISTER 4
ADDRESS 712
BACKGROUND
AND COLOR
Fig. 4-29. Color register organization for IVIodes 4, 6, and their
variations.
206
o>- ::::::::::
_
o_
_
g- :
>^- :::
S- - —
_
s- "
2- ::::::
ID- -"" —
tn—
o—
71 1 1 1
/ p in in
1 ' 1 1 111
s a s s n°
1
1
CNJ
1
o
u
mOU SOIHdVUO
Fig. 4-30. Column/row format for the Mode-4 screen.
207
g
HO
X Q
o
u
o
X
a.
<
DC
C9
I I I I
O T- CM CO
O
u
mOU SOIHdVUO
Fig. 4-31 . Column/row format for the Mode-6 screen.
208
Figs. 4-32 and 4-33 show the column/row formats for
screen Modes 20 and 22— the full-screen versions of
Modes 4 and 6, respectively.
Screen RAM Formats and Operations for Modes 4 and 6
Figs. 4-34 through 4-37 illustrate some key RAM addresses
for screen Modes 4, 6, 20, and 22. Tables 4-14 through 4-17
indicate the starting and ending addresses for each row. A
comparison of these RAM-addressing formats with the
corresponding column/row formats show an 8:1 ratio
between the number of columns per row and the number
of successive RAM addresses per row. Each byte of screen
data, in other words, cites the color register to be used by
8 successive pixel locations.
Fig. 4-38 shows the organization of the data byte that is
carried by each screen RAM address location. Each of the
8 bits carries a or 1 that corresponds to a COLOR desig-
nation for Mode-4 and Mode-6 graphics.
If you POKE a data byte that is equivalent to using ones
in all eight locations (decimal 255), the graphics system will
respond by plotting eight consecutive pixels from the
COLOR 1 register.
POKE a 170 into a screen RAM address and you will see
four pixels separated by background color. The binary
equivalent of 170 is:
10 10 10 10
And that will give alternate pixels a color that is different
from the background.
Table 4-18 makes it easier to determine the data values
whenever it is necessary to POKE it directly to the 2-color
screens.
209
S-:
o
u
M
o
X
Q.
<
(9
in o
'- CM
1^
o
MOU SOIHdVUO
Fig. 4-32. Column/row format for the Mode-20 screen.
210
o
o
u
X
a.
<
cc
a
MOU SOIHdVUO
Fig. 4-33. Column/row format for the Mode-22 screen.
211
I- o
O O O O
O TT 00 CM
00 CO 00 O)
o o o o o
■^ KJ- -^ tT ^
Fig. 4-34. Screen RAM address format for the Mode-4 screen. See a
detailed listing of the addresses in Table 4-14.
212
g
HO
39619
40479
-40839
-40879
-40919
i
o
1
111
>■
m
IE
lU
a.
!3
111
X
-1
4
1-
Z
o
N
o
X
eo
o o
O CD
CD ^
O) O
CO -*
1
o
o
00
o
1
o
1
O
CO
1
o
CNJ
Oi
o
Fig. 4-35. Screen RAM address format for the Mode-6 screen. See a
detailed listing of the addresses in Table 4-15.
213
ll 1 1
Lli "H
1- . __ ;
■»-
oD -::::::::::"::::::
Q. ::::: :::::: —
Uj _- _
z : -~ — - —
o - - ::
Nl - - -
o — - :::::
00
1 ■ -^^-^l
Fig. 4-36. ScreenRAMaddressformatfortheMode-20screen.Seea
detailed listing of the addresses in Table 4-16.
214
0>
CO
0>
>-
CD
IIJ
X
o.
O
N
OC
O
X
o
CO
oo
oo
Fig. 4-37. Screen RAM addressformatfortheMode-22screen.Seea
detailed listing of the addresses in Table 4-17.
215
Table 4-14. Starting and Ending Addresses
for Each Row of the Mode-4 Screen RAM
Row
Addresses
Row
Addresses
Start
End
Start
End
Row
40320
40329
Row 24
40560
40569
Row 1
40330
40339
Row 25
40570
40579
Row 2
40340
40349
Row 26
40580
40589
Row 3
40350
40359
Row 27
40590
40599
Row 4
40360
40369
Row 28
40600
40609
Row 5
40370
40379
Row 29
40610
40619
Row 6
40380
40389
Row 30
40620
40629
Row 7
40390
40399
Row 31
40630
40639
Row 8
40400
40409
Row 32
40640
40649
Row 9
40410
40419
Row 33
40650
40659
Row 10
40420
40429
Row 34
40660
40669
Row 11
40430
40439
Row 35
40670
40679
Row 12
40440
40449
Row 36
40680
40689
Row 13
40450
40459
Row 37
40690
40699
Row 14
40460
40469
Row 38
40700
40709
Row 15
40470
40479
Row 39
40710
40719
Row 16
AO^RO
40489
40499
Row 17
40490
Text wi
ndow begins here
Row 18
40500
40509
40519
Row 19
40510
Row
40800
40839
Row 20
40520
40529
Row 1
40840
40879
Row 21
40530
40539
Row 2
40880
40919
Row 22
40540
40549
Row 3
40920
40959
Row 23
40550
40559
THE 2-COLOR MODE-8 SCREEN
The Mode-8 screen offers the highest resolution of all. It
uses the same 8-bit screen-data format as Modes 4 and 6
(see Fig. 4-38), the same graphics commands, and the same
general 2-color scheme. Aside from the higher level of
resolution, the only difference between the Mode-8 and
other 2-color modes is the organization of the two color
registers.
216
Table 4-15. Starting and Ending Addresses
for Each Row of the Mode-6 Screen RAM
Row
Addresses |
Row
Addresses |
Start
End
Start
End
Row
38880
38899
Row 44
39760
39779
Row 1
38900
38919
Row 45
39780
39799
Row 2
38920
38939
Row 46
39800
39819
Row 3
38940
38959
Row 47
39820
39839
Row 4
38960
38979
Row 48
39840
39859
Row 5
38980
38999
Row 49
39860
39879
Row 6
39000
39019
Row 50
39880
39899
Row 7
39020
39039
Row 51
39900
39919
Row 8
39040
39059
Row 52
39920
39939
Row 9
39060
39079
Row 53
39940
39959
Row 10
39080
39099
Row 54
39960
39979
Row 11
39100
39119
Row 55
39980
39999
Row 12
39120
39139
Row 56
40000
40019
Row 13
39140
39159
Row 57
40020
40039
Row 14
39160
39179
Row 58
40040
40059
Row 15
39180
39199
Row 59
40060
40079
Row 16
39200
39219
Row 60
40080
40099
Row 17
39220
39239
Row 61
40100
40119
Row 18
39240
39259
Row 62
40120
40139
Row 19
39260
39279
Row 63
40140
40159
Row 20
39280
39299
Row 64
40160
40179
Row 21
39300
39319
Row 65
40180
40199
Row 22
39320
39339
Row 66
40200
40219
Row 23
39340
39359
Row 67
40220
40239
Row 24
39360
39379
Row 68
40240
40259
Row 25
39380
39399
Row 69
40260
40279
Row 26
39400
39419
Row 70
40280
40299
Row 27
39420
39439
Row 71
40300
40319
Row 28
39440
39459
Row 72
40320
40339
Row 29
39460
39479
Row 73
40340
40359
Row 30
39480
39499
Row 74
40360
40379
Row 31
39500
39519
Row 75
40380
40399
Row 32
39520
39539
Row 76
40400
40419
Row 33
39540
39559
Row 77
40420
40439
Row 34
39560
39579
Row 78
40440
40459
Row 35
Row 36
39580
39600
39599
39619
Row 79
40460
40479
Row 37
39620
39639
Text w
indow begin
s here
Row 38
39640
39659
Row 39
39660
39679
Row
40800
40839
Row 40
39680
39699
Row 1
40840
40879
Row 41
39700
39719
Row 2
40880
40919
Row 42
39720
39739
Row 3
40920
40959
Row 43
39740
39759
217
Table 4-16. Starting and Ending Addresses
for Each Row of the Mode-20 Screen RAIVI
Row
Addresses
Row
Addresses
Start
End
Start
End
Row
40320
40329
Row 24
40560
40569
Row 1
40330
40339
Row 25
40570
40579
Row 2
40340
40349
Row 26
40580
40589
Row 3
40350
40359
Row 27
40590
40599
Row 4
40360
40369
Row 28
40600
40609
Row 5
40370
40379
Row 29
40610
40619
Row 6
40380
40389
Row 30
40620
40629
Row 7
40390
40399
Row 31
40630
40639
Row 8
40400
40409
Row 32
40640
40649
Row 9
40410
40419
Row 33
40650
40659
Row 10
40420
40429
Row 34
40660
40669
Row 11
40430
40439
Row 35
40670
40679
Row 12
40440
40449
Row 36
40680
40689
Row 13
40450
40459
Row 37
40690
40699
Row 14
40460
40469
Row 38
40700
40709
Row 15
40470
40479
Row 39
40710
40719
Row 16
40480
40489
Row 40
40720
40729
Row 17
40490
40499
Row 41
40730
40739
Row 18
40500
40509
Row 42
40740
40749
Row 19
40510
40519
Row 43
40750
40759
Row 20
40520
40529
Row 44
40760
40769
Row 21
40530
40539
Row 45
40770
40779
Row 22
40540
40549
Row 46
40780
40789
Row 23
40550
40559
Row 47
40790
40799
Fig. 4-39 shows that the Mode-8 colors refer to register 1
and 2. This can cause some difficulty when working with
the text-window versions, because adjustments in the
graphics color will affect the luminance of the text-
window characters and both portions of the screen have
the same background color.
When adjusting the Mode-8 graphics color, you have
two options:
SETCOLOR ^.hue.lum
and
POKE 709, 16*/u/77 + hue
Conveniently, you can PLOT that color by first execut-
ing a COLOR 1 statement.
218
Table 4-17. Starting and Ending Addresses
for Each Row of the Mode-22 Screen RAM
Row
Addresses
Row
Addresses
Start
End
Start
End
Row
38880
38899
Row 36
39600
39619
Row 1
38900
38919
Row 37
39620
39639
Row 2
38920
38939
Row 38
39640
39659
Row 3
38940
38959
Row 39
39660
39679
Row 4
38960
38979
Row 40
39680
39699
Row 5
38980
38999
Row 41
39700
39719
Row 6
39000
39019
Row 42
39720
39739
Row 7
39020
39039
Row 43
39740
39759
Row 8
39040
39059
Row 44
39760
39779
Row 9
39060
39079
Row 45
39780
39799
Row 10
39080
39099
Row 46
39800
39819
Row 11
39100
39119
Row 47
39820
39839
Row 12
39120
39139
Row 48
39840
39859
Row 13
39140
39159
Row 49
39860
39879
Row 14
39160
39179
Row 50
39880
39899
Row 15
39180
39199
Row 51
39900
39919
Row 16
39200
39219
Row 52
39920
39939
Row 17
39220
39239
Row 53
39940
39959
Row 18
39240
39259
Row 54
39960
39979
Row 19
39260
39279
Row 55
39980
39999
Row 20
39280
39299
Row 56
40000
40019
Row 21
39300
39319
Row 57
40020
40039
Row 22
39320
39339
Row 58
40040
40059
Row 23
39340
39359
Row 59
40060
40079
Row 24
39360
39379
Row 60
40080
40099
Row 25
39380
39399
Row 61
40100
40119
Row 26
39400
39419
Row 62
40120
40139
Row 27
39420
39439
Row 63
40140
40159
Row 28
39440
39459
Row 64
40160
40179
Row 29
39460
39479
Row 65
40180
40199
Row 30
39480
39499
Row 66
40200
40219
Row 31
39500
39519
Row 67
40220
40239
Row 32
39520
39539
Row 68
40240
40259
Row 33
39540
39559
Row 69
40260
40279
Row 34
39560
39579
Row 70
40280
40299
Row 35
39580
39599
Row 71
40300
40319
219
Table 4-17— cont. Starting and Ending Addresses
for Each Row of the i\1ode-22 Screen RAM
Row
Addresses
Row
Addresses
Start
End
Start
End
Row 72
40320
40339
Row 84
40560
40579
Row 73
40340
40359
Row 85
40580
40599
Row 74
40360
40379
Row 86
40600
40619
Row 75
40380
40399
Row 87
40620
40639
Row 76
40400
40419
Row 88
40640
40659
Row 77
40420
40439
Row 89
40660
40679
Row 78
40440
40459
Row 90
40680
40699
Row 79
40460
40479
Row 91
40700
40719
Row 80
40480
40499
Row 92
40720
40739
Row 81
40500
40519
Row 93
40740
40759
Row 82
40520
40539
Row 94
40760
40779
Row 83
40540
40559
Row 95
40780
40799
SCREEN DATA BYTE
MSB LSB
PIXEL
D7
D6
D5
D4
D3
D2
D1
DO
1
2
3
4
5
6
7
LEFT
RIGHT
BIT
VALUE
EQUIVALENT
COLOR VALUE
REGISTER
USED
1
COLOR
COLOR 1
4
Fig. 4-38. Organization of screen data bytes for Modes 4. 6, and their
variations.
But when it comes to the background color, you must
SETCOLOR or POKE the information by designating regis-
ter 2; and then use a COLOR statement to access it.
220
Table 4-18. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6,8, and Their Variations)
(Left -
- Right)
Data
1
2
3
1
4
1
5
1
6
1
7
1
8
1
9
1
10
1
11
1 1
12
1 1
13
1 1
14
1 1
15
1
16
1
17
1
18
1
19
1
1
20
1
1
21
1
1
22
1
1
23
1
1
24
1
1
25
1
1
26
1
1
27
1
1 1
28
1
1 1
29
1
1 1
30
1
1 1
31
221
Table 4-1 8— cont. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6,8, and Their Variations)
(Left
- - Right)
Data
1
32
1
33
1
34
1
35
1
1
36
1
1
37
1
1
38
1
1
39
I
1
40
1
1
41
1
1
42
1
1
43
1 1
44
1 1
45
1 1
46
1 1
47
48
1
49
1
50
1
51
1
1
52
1
1
53
1
1
54
1
1
55
1
1
56
1
1
57
1
1
58
1
1
59
1
1 1
60
1
1 1
61
1
1 1
62
1
1 1
63
222
Table 4-1 8— cont. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6,8, and Their Variations)
/I aft
Riaht)
Data
1
1
1
1
64
65
66
67
1
1
1
1
1
1
1
1
68
69
70
71
1
1
1
1
1
1
1
1
72
73
74
75
1
1
1
1
1 1
1 1
1 1
1 1
76
77
78
79
1
1
t 1
1 1
80
81
82
83
1 1
1 1
1 1
1 1
1
1
1
1
84
85
86
87
1 1
1 1
1 1
1 1
1
1
1
1
88
89
90
91
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
92
93
94
95
223
Table 4-1 8— cont. Color Register Sequences and
Screen Data Bytes for 8-Plxel/Bit Screens
(Modes 4,6,8. and Their Variations)
(Left
— Right)
Data
1
1
1
1
1
1
1
1
96
97
98
99
1
1
1
1
1
1
1
1
1
1
1
1
100
101
102
103
1
1
1
1
1
1
1
1
1
1
1
1
104
105
106
107
1
1
1
1
1
1
1
1
1 1
1 1
1 1
1 1
108
109
110
111
1
1
1
1
112
113
114
115
1
1
1
1
1
1
1
1
116
117
118
119
1
1
1
1
1
1
1
1
120
121
122
123
1
1
1
1
1 1
1 1
1 1
1 1
124
125
126
127
224
Table 4-18— cont. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6,8, and Their Variations)
(Left
— Right)
Data
1
1
1
1
1
1
128
129
130
131
1
1
1
1
1
1
1
1
1
1
132
133
134
135
1
1
1
1
1
1
1
1
1
1
136
137
138
139
1
1
1
1
1 1
1 1
1 1
1 1
1
1
140
141
142
143
1
1
1
1
1
1
1
1
1
1
144
145
146
147
1
1
1
1
1
1
1
1
1
1
1
1
1
1
148
149
150
151
1
1
1
1
1
1
1
1
1
1
1
1
1
1
152
153
154
155
1
1
1
1
1
1
1
1
1 1
1 1
1 1
1 1
1
1
156
157
158
159
225
Table 4-18— cont. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6.8. and Their Variations)
(Left
Right)
Data
1
1
1
1
1
1
1
1
160
161
162
163
1
1
1
1
1
1
1
1
1
1
1
1
164
165
166
167
1
1
1
1
1
1
1
1
1
1
1
1
168
169
170
171
1
1
1
1
1 1
1 1
1 1
1 1
172
173
174
175
1
1
1 1
1 1
176
177
178
179
1 1
1 1
1 1
1 1
1
1
1
1
180
181
182
183
1 1
1 1
1 1
1 1
1
1
1
1
1
184
185
186
187
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
188
189
190
191 1
226
Table 4-1 8— cont. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6,8, and Their Variations)
M ftft
Riaht)
Data
110
110
110
110
192
193
194
195
ooo o
o oo o
1
1
1
1
196
197
198
199
110
110
110
110
1
1
1
1
200
201
202
203
o ooo
oo oo
1 1
1 1
1 1
1 1
204
205
206
207
110 1
110 1
110 1
110 1
208
209
210
211
110 1
110 1
110 1
110 1
1
1
1
1
212
213
214
215
110 1
110 1
110 1
110 1
1
1
1
1
216
217
218
219
110 1
110 1
110 1
110 1
1 1
1 1
1 1
1 1
220
221
222
223
227
Table 4-18— cont. Color Register Sequences and
Screen Data Bytes for 8-Pixel/Bit Screens
(Modes 4,6,8, and Their Variations)
(Left - —
— Right)
Data
1110
1110
1110
1110
224
225
226
227
1110
1110
1110
1110
1
1
1
1
228
229
230
231
1110
1110
1110
1110
1
1
1
1
232
233
234
235
1110
1110
1110
1110
1 1
1 1
1 1
1 1
236
237
238
239
240
241
242
243
1
1
1
1
244
245
246
247
1
1
1
1
248
249
250
251
1 1
1 1
1 1
1 1
252
253
254
255
228
TEXT WINDOW
USABLE
GRAHICS
MODES
NOT USED
REGISTER
ADDRESS 708
NOT USED
CHARACTER
LUMINANCE
REGISTER 1
ADDRESS 709
COLOR 1
CHARACTER HUE
AND BACKGROUND
COLOR
REGISTER 2
ADDRESS 710
BACKGROUND
NOT USED
REGISTER 3
ADDRESS 711
NOT USED
BORDER
COLOR
REGISTER 4
ADDRESS 712
BORDER
COLOR
Fig. 4-39. Organization of color registers for the IVIode-8 screen.
Fig. 4-40 shows the row/column format for the Mode-8
screen. Notice that it uses 320 columns (labeled through
310) and 160 graphics rows (0 through 159). That figures
out to be 51,200 pixel locations. Fig. 4-41, however, shows
that the 8-pixel-per-byte scheme allows the system to do
the job with just 6400 bytes of screen RAM.
Table 4-19 shows the first and last addresses for each
row of the screen's RAM area.
Screen Mode 24 is a Mode-8 screen without the text
window. Fig. 4-42 shows its 320-column, 192-row format.
Fig. 4-43 indicates the screen RAM addressing range, and
Table 4-20 details the RAM addressing range for each row.
229
5
t- o
o
u
M
u
z
a.
<
o
o
I-
X
UI
1-
>-'
O »- CM (O
MOU SOIHdVUO
Fig. 4-40. Column/row format for the Mode-8 screen.
230
l-O
lU
a
-J
<
33143
39503
-40839
-40879
-40919
i
T
33104
39464
1
o
1
o
GO
o
1
o
1
Fig. 4-41 . Screen RAM address format for the Mode-8 screen. See a
detailed listing of the addresses in Table 4-19.
231
Table 4-19. Starting and Ending Addresses
for Each Row of the Mode-8 Screen RAM
Row
Addresses
Addresses
Start
End
Row
Start
End
Row
33104
33143
Row 42
34784
34823
Row 1
33144
33183
Row 43
34824
34863
Row 2
33184
33223
Row 44
34864
34903
Row 3
33224
33263
Row 45
34904
34943
Row 4
33264
33303
Row 46
34944
34983
Row 5
33304
33343
Row 47
34984
35023
Row 6
33344
33383
Row 48
35024
35063
Row 7
33384
33423
Row 49
35064
35103
Row 8
33424
33463
Row 50
35104
35143
Row 9
33464
33503
Row 51
35144
35183
Row 10
33504
33543
Row 52
35184
35223
Row 11
33544
33583
Row 53
35224
35263
Row 12
33584
33623
Row 54
35264
35303
Row 13
33624
33663
Row 55
35304
35343
Row 14
33664
33703
Row 56
35344
35383
Row 15
33704
33743
Row 57
35384
35423
Row 16
33744
33783
Row 58
35424
35463
Row 17
33784
33823
Row 59
35464
35503
Row 18
33824
33863
Row 60
35504
35543
Row 19
33864
33903
Row 61
35544
35583
Row 20
33904
33943
Row 62
35584
35623
Row 21
33944
33983
Row 63
35624
35663
Row 22
33984
34023
Row 64
35664
35703
Row 23
34024
34063
Row 65
35704
35743
Row 24
34064
34103
Row 66
35744
35783
Row 25
34104
34143
Row 67
35784
35823
Row 26
34144
34183
Row 68
35824
35863
Row 27
34184
34223
Row 69
35864
35903
Row 28
34224
34263
Row 70
35904
35943
Row 29
34264
34303
Row 71
35944
35983
Row 30
34304
34343
Row 72
35984
36023
Row 31
34344
34383
Row 73
36024
36063
Row 32
34384
34423
Row 74
36064
36103
Row 33
34424
34463
Row 75
36104
36143
Row 34
34464
34503
Row 76
36144
36183
Row 35
34504
34543
Row 77
36184
36223
Row 36
34544
34583
Row 78
36224
36263
Row 37
34584
34623
Row 79
36264
36303
Row 38
34624
34663
Row 80
36304
36343
Row 39
34664
34703
Row 81
36344
36383
Row 40
34704
34743
Row 82
36384
36423
Row 41
34744
34783
Row 83
36424
36463
232
Table 4-19— cont. Starting and Ending Addresses
for Each Row of the IVIode-8 Screen RAM
Row
Addresses
Row
Addresses
Start
End
Start
End
Row 84
36464
36503
Row 126
38144
38183
Row 85
36504
36543
Row 127
38184
38223
Row 86
36544
36583
Row 128
38224
38263
Row 87
36584
36623
Row 1 29
38264
38303
Row 88
36624
36663
Row 1 30
38304
38343
Row 89
36664
36703
Row 131
38344
38383
Row 90
36704
36743
Row 1 32
38384
38423
Row 91
36744
36783
Row 133
38424
38463
Row 92
36784
36823
Row 134
38464
38503
Row 93
36824
36863
Row 1 35
38504
38543
Row 94
36864
36903
Row 136
38544
38583
Row 95
36904
36943
Row 1 37
38584
38623
Row 96
36944
36983
Row 1 38
38624
38663
Row 97
36984
37023
Row 139
38664
38703
Row 98
37024
37063
Row 1 40
38704
38743
Row 99
37064
37103
Row 141
38744
38783
Row 100
37104
37143
Row 142
38784
38823
Row 101
37144
37183
Row 143
38824
38863
Row 102
37184
37223
Row 144
38864
38903
Row 1 03
37224
37263
Row 145
38904
38943
Row 104
37264
37303
Row 146
38944
38983
Row 1 05
37304
37343
Row 147
38984
39023
Row 106
37344
37383
Row 148
39024
39063
Row 107
37384
37423
Row 149
39064
39103
Row 108
37424
37463
Row 1 50
39104
39143
Row 109
37464
37503
Row 151
39144
39183
Row 110
37504
37543
Row 1 52
39184
39223
Row 1 1 1
37544
37583
Row 153
39224
39263
Row 1 1 2
37584
37623
Row 154
39264
39303
Row 1 1 3
37624
37663
Row 155
39304
39343
Row 114
37664
37703
Row 1 56
39344
39383
Row 1 1 5
37704
37743
Row 1 57
39384
39423
Row 1 1 6
37744
37783
Row 1 58
39424
39463
Row 117
37784
37823
Row 159
39464
39503
Row 1 1 8
37824
37863
Row 1 1 9
37864
37903
Text wir
idow begin
s here
Row 120
37904
37943
Row 121
37944
37983
Row
40800
40839
Row 1 22
37984
38023
Row 1
40840
40879
Row 123
38024
38063
Row 2
40880
40919
Row 1 24
38064
38103
Row 3
40920
40959
Row 1 25
38104
38143
233
o
o
CO
O
X
Q.
f
«
MOU SOIHdVUO
Fig. 4-42. Column/row format for the Mode-24 screen.
234
CO
>-
o
a
111
a.
w
_j
u
o
N
o
Fig. 4-43. ScreenRAMaddressformatfortheMode-24screen. Seea
detailed listing of the addresses in Table 4-20.
235
Table 4-20. Starting and Ending Addresses
for Each Row of the Mode-24 Screen RAIVI
Row
Addresses
Row
Addresses
Start
End
Start
End
Row
33104
33143
Row 36
34544
34583
Row 1
33144
33183
Row 37
34584
34623
Row 2
33184
33223
Row 38
34624
34663
Row 3
33224
33263
Row 39
34664
34703
Row 4
33264
33303
Row 40
34704
34743
Row 5
33304
33343
Row 41
34744
34783
Row 6
33344
33383
Row 42
34784
34823
Row 7
33384
33423
Row 43
34824
34863
Row 8
33424
33463
Row 44
34864
34903
Row 9
33464
33503
Row 45
34904
34943
Row 10
33504
33543
Row 46
34944
34983
Row 11
33544
33583
Row 47
34984
35023
Row 12
33584
33623
Row 48
35024
35063
Row 13
33624
33663
Row 49
35064
35103
Row 14
33664
33703
Row 50
35104
35143
Row 15
33704
33743
Row 51
35144
35183
Row 16
33744
33783
Row 52
35184
35223
Row 17
33784
33823
Row 53
35224
35263
Row 18
33824
33863
Row 54
35264
35303
Row 19
33864
33903
Row 55
35304
35343
Row 20
33904
33943
Row 56
35344
35383
Row 21
33944
33983
Row 57
35384
35423
Row 22
33984
34023
Row 58
35424
35463
Row 23
34024
34063
Row 59
35464
35503
Row 24
34064
34103
Row 60
35504
35543
Row 25
34104
34143
Row 61
35544
35583
Row 26
34144
34183
Row 62
35584
35623
Row 27
34184
34223
Row 63
35624
35663
Row 28
34224
34263
Row 64
35664
35703
Row 29
34264
34303
Row 65
35704
35743
Row 30
34304
34343
Row 66
35744
35783
Row 31
34344
34383
Row 67
35784
35823
Row 32
34384
34423
Row 68
35824
35863
Row 33
34424
34463
Row 69
35864
35903
Row 34
34464
34503
Row 70
35904
35943
Row 35
34504
34543
Row 71
35944
35983
236
Table 4-20— cont. Starting and Ending Addresses
for Each Row of the Mode-24 Screen RAM
Ro^u
Addresses
Row
Addresses
Start
End
Start
End
Row
72
35984
36023
Row 107
37384
37423
Row
73
36024
36063
Row 1 08
37424
37463
Row
74
36064
36103
Row 109
37464
37503
Row
75
36104
36143
Row 110
37504
37543
Row
76
36144
36183
Row 1 1 1
37544
37583
Row
77
36184
36223
Row 1 1 2
37584
37623
Row
78
36224
36263
Row 1 1 3
37624
37663
Row
79
36264
36303
Row 114
37664
37703
Row
80
36304
36343
Row 1 1 5
37704
37743
Row
81
36344
36383
Row 1 1 6
37744
37783
Row
82
36384
36423
Row 1 1 7
37784
37823
Row
83
36424
36463
Row 1 1 8
37824
37863
Row
84
36464
36503
Row 1 1 9
37864
37903
Row
85
36504
36543
Row 1 20
37904
37943
Row
86
36544
36583
Row 121
37944
37983
Row
87
36584
36623
Row 122
37984
38023
Row
88
36624
36663
Row 1 23
38024
38063
Row
89
36664
36703
Row 1 24
38064
38103
Row
90
36704
36743
Row 1 25
38104
38143
Row
91
36744
36783
Row 126
38144
38183
Row
92
36784
36823
Row 1 27
38184
38223
Row
93
36824
36863
Row 1 28
38224
38263
Row
94
36864
36903
Row 1 29
38264
38303
Row
95
36904
36943
Row 130
38304
38343
Row
96
36944
36983
Row 131
38344
38383
Row
97
36984
37023
Row 132
38384
38423
Row
98
37024
37063
Row 1 33
38424
38463
Row
99
37064
37103
Row 134
38464
38503
Row 100
37104
37143
Row 135
38504
38543
Row 1 01
37144
37183
Row 1 36
38544
38583
Row 102
37184
37223
Row 137
38584
38623
Row 103
37224
37263
Row 1 38
38624
38663
Row 104
37264
37303
Row 139
38664
38703
Row 105
37304
37343
Row 140
' 38704
38743
Row 1 06
37344
37383
Row 141
38744
38783
237
Table 4-20-cont. Starting and Ending Addresses
for Each Row of the Mode-24 Screen RAM
Row
Row 142
Row 143
Row 144
Row 145
Row 146
Row 147
Row 148
Row 149
Row 1 50
Row 151
Row 1 52
Row 1 53
Row 154
Row 1 55
Row 1 56
Row 1 57
Row 1 58
Row 1 59
Row 160
Row 1 61
Row 1 62
Row 1 63
Row 164
Row 1 65
Row 1 66
Addresses
Start
38784
38824
38864
38904
38944
38984
39024
39064
39104
39144
39184
39224
39264
39304
39344
39384
39424
39464
39504
39544
39584
39624
39664
39704
39744
End
38823
38863
38903
38943
38983
39023
39063
39103
39143
39183
39223
39263
39303
39343
39383
39423
39463
39503
39543
39583
39623
39663
39703
39743
39783
Row
Row 1 67
Row 1 68
Row 1 69
Row 1 70
Row 171
Row 1 72
Row 173
Row 1 74
Row 1 75
Row 1 76
Row 1 77
Row 1 78
Row 1 79
Row 1 80
Row 181
Row 1 82
Row 1 83
Row 184
Row 1 85
Row 1 86
Row 1 87
Row 1 88
Row 1 89
Row 1 90
Row 191
Addresses
Start
39784
39824
39864
39904
39944
39984
40024
40064
40104
40144
40184
40224
40264
40304
40344
40384
40424
40464
40504
40544
40584
40624
40664
40704
40744
End
39823
39863
39903
39943
39983
40023
40063
40103
40143
40183
40223
40263
40303
40343
40383
40423
40463
40503
40543
40583
40623
40663
40703
40743
40783
238
Chapter 5
Player/Missile Graphics
The ATARI home computer system features an enhanced
animation package that generally goes by the name,
player/missile graphics. The name is derived from the
terminology that was applied to the original ATARI arcade
game systems; and, indeed, the computer player/missile
graphics retains many other general features of those
highly successful systems.
Generally speaking, those games involved some figures
that could be moved about on the screen (cannons, tanks,
airplanes, and the like), and a different kind of figure-
usually a simpler one— that is "fired" from the moving
objects. The former was termed the player and the latter
the missile. The terminology remains with ATARI systems,
even though the original ideas have been superceded by a
great many improvements and technological develop-
ments.
The ATARI 400/800 systems allow you to work with four
different player and missile figures simultaneously (and
even more if one cares to master some special program-
ming tricks).
239
Player/missile graphics is something quite different
from the other graphics and character modes that are de-
scribed in the previous chapter. In the context of the dis-
cussions in this chapter, it is more meaningful to refer to
those graphics and character modes as playfield graphics.
The reasoning behind that bit of terminology is that the
graphics modes provide colorful background and fore-
ground material for the animated player-and-missile
figures.
It is certainly possible to combine playfield and player/
missile graphics. In fact, it is difficult to avoid the tempta-
tion of drawing some interesting and colorful playfield
material to support the appearance and meaning of player/
missile animation. The two kinds of ATARI graphics func-
tion quite differently from one another, however. And
unlike the playfield graphics, there are no BASIC state-
ments that relate directly to player/missile operations.
Anyone who does not feel comfortable with the notion
of writing programs that are largely composed of PEEK and
POKE statements will have some difficulty with player/
missile graphics. All of the main player/missile operations
refer to register addresses rather than convenient BASIC
statements and functions.
The best approach to player/missile graphics is thus
through the mechanisms of 6502 machine language.
In short, readers whose understanding of the ATARI
programming is limited to BASIC are going to have some
difficulty dealing with the full potential of player/missile
graphics.
PLAYER AND MISSILE CONFIGURATIONS
The player and missile figures, up to four each, are all
bit-mapped figures. Designing and loading the figures
into a well-defined area of RAM is, in a sense, much the
same as designing and entering custom text/graphics
character sets as described at the end of Chapter 4.
240
Bit Maps for the Player Figures
All player figures are mapped as exactly 8 bits wide. Exactly
how those eight bits translate into width as the figures
appear on the screen depends on the values that are
POKEd into certain register locations. The important point
here is that each line in a player figure is established by a
single byte of data.
The number of successive 1-line bytes in the player-
figure bit map determines its vertical length on the screen.
The map must consist of exactly 128 or 256 bytes— no
more, and no less. The 128-byte versions will use 1 byte of
mapped data for every two horizontal scan lines on the tv
or monitor; and the 256-byte version will use 1 byte for
each horizontal scan line. The vertical resolution of the
128-byte version of a player figure is thus half that of the
256-byte version.
In either case, a player-figure bit map that uses mean-
ingful color information throughout its entirety will pro-
duce a figure that extends the entire height of the screen.
But that does not mean that every player figure has to
appear that large. Portions of the bit map that contain
binary will be invisible; so you can create short figures
by first setting all of the map addresses to 0, and then
loading only those bytes that define the figure you want to
see on the screen.
Designing a bit map for a player figure is a straightfor-
ward, if somewhat, tedious task. The usual technique is to
score a sheet of graph paper such that you work with a
figure window that is exactly 8 squares wide and as long as
necessary (not exceeding the 128- or 255-bit limits).
241
Fig. 5-1 illustrates the map-development procedure for
a 9-line player figure. The dark areas in Fig. 5-1A are to be
colored, and the light areas are to be invisible. That pat-
tern then translates to binary Is and Os as shown in Fig.
5-1 B—1 = colored, = invisible. The final step, shown in
Fig. 5-1C, translates the binary codes to decimal and hex-
adecimal formats. (The decimal format is most useful
when POKEing the data to the bit map, and the hexade-
cimal format is better when loading the bit map by means
of a 6502 assembly language routine.)
1-LINEPER-BYTE
BYTE PLAYER FIGURE
(A) Sketch the figure on square
graph paper, using 8 squares
per line.
BINARY DATA
1 10
10 10
10 10
10 10
10 10
1 10
110
11110
110
REMAINING 247 BYTES
ARE SET TO
(B) Translate the drawing into bi-
nary bytes: = bacl^ground
color, 1 = figure color.
DECIMAL
DATA
24
36
36
24
24
(C) Convert the binary format to
decimal.
Fig. 5-1 . Development of a player bit map.
242
Bearing in mind that the bit map for a player figure must
be divided into 1-byte lines, a bit map merely suggests the
general proportions of the player figure, and not necessar-
ily its size as it will eventually appear on the screen. And
the fact that this particular example uses only 9 bytes does
not change the fact that its bit map must be either 128 or
256 bytes long. A later discussion suggests a simple tech-
nique for filling the remainder of a figure's bit map with
zeros.
It is possible, but certainly not necessary, to develop
three more player-figure bit maps. In fact, you can use the
bit-map areas for any unused player figures for other pur-
poses such as machine-language programs. Suppose, for
example, that you are using player figures and 1, and
have no intention of using figures 2 and 3. You must
commit the entire bit-map area for figures and 1 to that
purpose, but then the areas that are normally set aside for
figures 2 and 3 are free for other uses.
Bit Maps for the Missile Figures
Missile figures, up to four of them, are likewise bit
mapped into RAM. Mapping a creates an "invisible"
point and mapping a 1 creates a point of some desired
color. And like player figures, missiles must be mapped as
either 128 or 256 bytes — even if it means POKEing a lot of
zeros to fill out that much space.
One big difference between the player and missile bit
maps is the fact that each missile figure is defined in terms
of 2 bits instead of 8. The missile map is 128 or 256 bytes
long; but for a given missile figure, it is only 2 bits {Va byte)
wide.
For the sake of RAM efficiency, the four missile figures
are lined up side by side. Fig. 5-2 shows how a single byte
accounts for line data for all four missile figures.
243
BYTE
1
MIS
D7
3ILE
i
D6
MISSILE
2
D5 D4
MISSILE
1
D3 D2
MISSILE
D1 DO
MSB
LSB
U-v,
^-^
J
UP TO BYTE 1023 FOR 2-LINE RESOLUTION
UP TO BYTE 2047 FOR 1-LINE RESOLUTION
Fig. 5-2. Organization of the bit map for missile figures.
The two most-significant bits (D7 and D6) are devoted to
missile figure M3, bits D5 and D4 are devoted to missile
figure M2, bits D3 and D2 are devoted to missile figure
Ml, and the two least-significant bits (D1 and DO) are
devoted to missile figure MO. Missile figure MO, for
instance, will occupy the two least-significant bits of the
missile bytes.
Having just 2 bits for each bit-mapped missile byte
doesn't leave a whole lot of room for applying one's crea-
tive imagination. It is possible, however, to salvage the
idea by combining two different missile figures into one
(and making certain that they remain side by side
throughout their animation routines).
244
The Overall Player/Missile Bit Map
Fig. 5-3 shows the two kinds of player/missile bit maps.
You must use one or the other, and you must set aside the
full amount of memory.
2 LINES PER BYTE
128-
256-
384
512-
640-
768-
896'
1024-
UNUSED
M3
M2
Ml
MO
PO
1 LINE PER BYTE
UNUSED
P3
M2
-128
-256
-384
512
-640
768
MO 1-896
1024
PO
PI
-1152
1280
-1408
1536
-1662
1792
P3
-1920
2048
Fig. 5-3. The overall player/missile bit map for 2-line and 1-line
vertical resolution.
The 2-lines-per-byte configuration devotes two hori-
zontal scan lines per byte of player/missile data. In that
instance, the space devoted to player and missile figures
fills the screen— from top to bottom— with just 128 bytes
per figure.
245
The 1-line-per-byte configuration offers a greater level
of vertical resolution, but of course requires twice as
much RAM to do the job. In that instance, there is 256
bytes set aside for each figure.
So if you elect to use the 2-lines-per-byte configuration,
the player/missile bit map must occupy a total of 1024
bytes— no matter how many figures you choose to use, or
how large or small they might be. Likewise, using the 1-
line-per-byte configuration demands that you set aside
2048 bytes of memory for the bit maps.
The fact that you must set aside either 1024 or 2048 bytes
of RAM for the player/missile bit map is not really a waste
of good memory. If you are using just two player figures,
for example, it is quite possible to use the RAM that is
allocated for the other two player figures for machine-
language programs. You are also free to use the unused
RAM areas for your own purposes.
Actually, this business of having to fill the unused areas
of the player/missile bit map with zeros is a rather trivial
one. Once you have established the starting address of the
bit map, called PMBASE, zeroing all the 2-lines-per-byte
area is a matter of executing this sort of BASIC routine:
FOR N=0TO 1023:POKE PMBASE+N,0:NEXT N
Or when using the 2048-byte version:
FOR N-OTO 2047:POKE PI\/1BASE+N,0:NEXT N
After setting all of the bit-map locations to zero, then
the player/missile data and any custom machine-language
programming can be POKEd or loaded into the map area.
The only critical problem in the entire affair is that of
determining the value of PMBASE— the base address for
the player/missile bit map.
246
Setting the Starting Address of the Player/Missile Bit
Map
The player/missile bit map must be located in a section of
RAM where it can be protected from the operating system
and BASIC, and yet in an area where there is no conflict
with the playfield graphics operations. The usual location
is just below the ANTIC display list for the playfield graph-
ics; but even then it is necessary to contend with the fact
that the location of the display list changes with the graph-
ics modes and the amount of RAM installed in the compu-
ter (see Chapters 7 and 8).
What's more, PMBASE must begin at a Ik boundary
value for a 1024-byte map, or at a 2k boundary value for a
2048-byte map.
Those might appear to be rather severe and trouble-
some restrictions upon the placement of the player/mis-
sile bit maps. But there is a reliable step-by-step proce-
dure for carrying out the task.
The procedure begins by determining the starting
addresses of all the playfield display lists you will be using,
and then select the one having the lowest address.
You can determine the starting address of a display list
by entering this program, setting up the playfield graphics
mode, and then executing the program:
10 D1SPL=PEEK(560)+256*(561)
20 GRAPHICS
30 PRINT DISPL
The LSB of the starting address of the display list is carried
in RAM address 560, and the MSB is in address 561. The
program thus PEEKs into those areas, converts the result to
a decimal number and prints it to the Mode-0 screen.
The starting address of the player/missile bit map must
then be at least 1024 or 2048 bytes lower— but at a Ik or 2k
boundary value.
247
Table 5-1 shows all possible Ik and 2k boundary values
for the ATARI system. If you are using the 1024-byte ver-
sion of a player/missile bit map, subtract 1024 from the
lowest display-list address, and then use the table to find
the next-lower Ik boundary value. So if your lowest-
numbered display list happens to begin at address 40540,
and you are using a 1024-byte player/missile bit map,
then:
40540-1024 = 39516
Table 5-1. Ik and 2k
Boundary Values for RAM Addresses
Ik
2k
1024
32768
2048
2048
33792
4096
3072
34816
6144
4096
35840
8192
5120
36864
10240
6144
37888
12288
7168
38912
14336
8192
39936
16384
9216
40960
18432
10240
41984
20480
11264
43008
22528
12288
44032
24576
13312
45056
26624
14336
46080
28672
15360
47104
30720
16384
48128
32768
17408
49152
34816
18432
50176
36864
19456
51200
38912
20480
52224
40960
21504
53248
43008
22528
54272
45056
23552
55296
47104
24576
56320
49152
25600
57344
51200
26624
58368
53248
27648
59392
55296
28672
60416
57344
29696
61440
59392
30720
62464
61440
31744
63488
64512
63488
248
But 39516 does not represent a Ik boundary value.
According to the Ik boundary-value list in Table 5-1, the
next-lower address is 38912— and that is a Ik boundary
value. Thus, the player/missile bit-map should begin at
address 38912.
By way of another example, suppose that you want to
use a 2048-byte map, and your lowest-addressed display
list begins at 40266. Subtracting those values:
40266 2048-38218
And according to the 2k boundary table, the next-lower
address is 36864. That is where the 2048-byte bit map
should begin in this particular example.
If you do not feel inclined to do all of those calculations
yourself, you can let the ATARI Home Computer do the
work for you:
10 PRINT "SELECT ONE:"
20 PRINT" 1— SINGLE-LINE RESOLUTION
30 PRINT " 2— DOUBLE-LINE RESOLUTION
40 INPUT R
50 R=INT(R);IF N0T(R=1 OR R=2)THEN 40
60 DLST=PEEK(560)+256*PEEK(561)
70 IF R=1 THEN D=2048:GOTO 90
80 D=1024
90 PMBA=INT(DLST/D-1)*D
100 PRINT "DISPLAY LIST STARTS AT: ";DLST
110 PRINT "BIT MAP SHOULD START AT: ^PMBA
Protecting the Player/Missile Bit Map
It is important to protect the player/missile bit map from
operating-system and BASIC RAM operations. Once you
know the starting address of the bit map, simply derive a
2-byte decimal version of it and POKE the LSB into RAM
address 14 and the MSB into address 15. Those two
addresses, often labeled APPEMHI set the highest RAM
address that is available for operating-system and BASIC
operations. A program that uses player/missile graphics
should thus have POKEs to addresses 14 and 15 appearing
249
very early in the listing; certainly before attempting to set
up the bit map.
ADJUSTING THE WIDTH OF THE PLAYER/MISSILE
FIGURES
The selection of single- or double-line resolution has a lot
to do with the vertical size of a player/missile figure; and,
of course, so does the length of the bit map for those
figures. The bit map, however, allows player figures to be
only 8 pixels wide and missile figures to be just 1 pixel
wide. Obviously, there are going to be instances where
you want to use figures that are much wider than that— at
least they should appear wider on the screen.
There are some registers available for expanding the
width of the player/missile figures; specifically, it is possi-
ble to double or quadruple their width. Table 5-2 shows
the RAM addresses of those width-control registers and
the data bytes that should be POKEd to them in order to
get 1x, 2x or 4x horizontal expansion.
Table 5-2. Player/Missile Figure Width Registers
Width-Register
Width-Register
Figure(s)
Label
Address
Affected
SIZE PC
53256
Player
SIZEP1
53257
Player 1
SIZEP2
53258
Player 2
SIZEP3
53259
Player 3
SIZEM
53260
Missiles through 3
POKE values:
0= norma I width (1x bit-map width)
1=double width (2x bit-map width)
2=quadruple width (4x bit-map width)
Notice that it is possible to adjust the width of the four
player figures independently. The scheme, however,
allows just one width setting for all four missiles.
The default width is 1x. So if you plan to use alternative
widths, it is important to POKE into the width-setting
addresses very early in the program.
250
SETTING PLAYER/MISSILE COLORS
The color of the player/missile figures is set according to
the same scheme that is used for playfield graphics. In that
regard, Table 4-1 lists the basic hues and their data values,
and Table 4-2 shows the relevant luminance values that
must be summed with 16*hue to get a desired color. The
player/missile figures, however, use a different set of
RAM addresses for their color registers.
Table 5-3 shows the addresses of the color registers for
player/missile figures through 3. Notice that a given
player figure and its corresponding missile share the same
color register. Because of that particular feature, a player
and its corresponding missile will always have the same
color.
Table 5-3.
Player/Missile Color Registers
Color-Register
Label
Color-Register
Address
Figures
Affected
COLPMO
C0LPM1
C0LPM2
C0LPM3
707
708
709
710
Player/Missile
Player/Missile 1
Player/Missile 2
Player/Missile 3
NOTE: See Tables 4-1 and 4-2 in Chapter 4 for listings of appropriate
hue and luminance data values.
Naturally, it is important to POKE the desired player/
missile colors into the color registers before initiating rou-
tines that display them on the screen.
INITIATING AND TERMINATING PLAYER/MISSILE
GRAPHICS
The mere presence of a player/missile bit map and the
setting of width color registers is not sufficient for initiat-
ing player/missile graphics modes. Two additional regis-
ters must be loaded with data that configures the entire
scheme. The registers are GRACTL (address 53277) and
DMACTL (address 559). GRACTL enables and disables the
251
player/missile graphics, and DMACTL is used for setting
up a desired player/missile configuration.
Table 5-4 shows the relevant data values that can be
POKEd to GRACTL.
Table 5-4. POKE Operations for the GRACTL
(Graphics Control) Register
POKES to GRACTL
POKE 53277,0
POKE 53277,1
POKE 53277,2
POKE 53277,3
Function
Disable all player/missile operations
Enable missiles only
Enable players only
Enable both players and missiles
NOTE: Add 4 to the data values to latch all paddle trigger inputs. Using
the values shown here will clear and disable the paddle trigger latches.
It Is not sufficient to deal only with GRACTL. Every
GRACTL should follow a POKE statement to DMACTL at
address 559— a statement that actually configures the
graphics operations.
Table 5-5 shows all possible playfield and player/missile
configurations. Notice that the value POKEd to DMACTL
must be greater than or equal to 32. POKEing values less
than 32 will disable ANTIC altogether, thereby making it
impossible to work with any kind of graphics— including
normal Mode-0 text.
Those POKE-to-559 values offer a wide range of options.
The default value, for example, is 34. From the table, you
can see that it specifies a normal-sized playfield and dis-
ables the player/missile graphics.
It is often desirable to adjust those values during the
execution of a program, but there is one parameter that
ought to remain unchanged— the number of lines of reso-
lution. That figure must match the choice you made ear-
lier when setting up the player/missile bit map.
Generally, a programmer will first set up the DMACTL
register, followed immediately by POKEing the appro-
priate value to GRACTL.
252
Table 5-5. POKE Values for Configuring the
Player/ Missile Operations at the DMACTL
(Direct-Memory-Address Control) Register
POKE
Playfield
Missile
Player
Vertical
Value
Configuration
Status
Status
Resolution
32
none
disable
disable
not relevant
33
narrow
disable
disable
not relevant
34
standard
disable
disable
not relevant
35
wide
disable
disable
not relevant
36
none
enable
disable
2-line
37
narrow
enable
disable
2-line
38
standard
enable
disable
2-line
39
wide
enable
disable
2-line
40
none
disable
enable
2-line
41
narrow
disable
enable
2-line
42
standard
disable
enable
2-line
43
wide
disable
enable
2-line
44
none
enable
enable
2-line
45
narrow
enable
enable
2-line
46
standard
enable
enable
2-line
47
wide
enable
enable
2-line
48
none
disable
disable
not relevant
49
narrow
disable
disable
not relevant
50
standard
disable
disable
not relevant
51
wide
disable
disable
not relevant
52
none
enable
disable
1-line
53
narrow
enable
disable
1-line
54
standard
enable
disable
1-line
55
wide
enable
disable
1-line
56
none
disable
enable
l-line
57
narrow
disable
enable
1-line
58
standard
disable
enable
1-line
59
wide
disable
enable
1-line
60
none
enable
enable
l-line
61
narrow
enable
enable
1-line
62
standard
enable
enable
1-line
63
wide
enable
enable
1-line
253
MOVING THE PLAYER/MISSILE FIGURES
Moving player and missile figures horizontally across the
screen is a relatively simple operation— just POKE the
desired column number into a register that is designated
for that purpose. The POKEd value will determine the
column location of the left-hand side of the bit-mapped
figure, and the range of useful values depends on the
figure's bit-mapped width and its width-register setting.
Table 5-6 lists the horizontal position registers for the
eight player and missile figures.
Table 5-6. The Horizontal 6-Position Registers
for the Player/Missile Figures
Label
Address
Figure
Affected
HPOSPO
53248
Player
HP0SP1
53249
Player 1
HP0SP2
53250
Player 2
HPOSP3
53251
Player 3
HPOSMO
53252
Missile
HP0SM1
53253
Missile 1
HP0SM2
53254
Missile 2
HP0SM3
53255
Missile 3
POKEing horizontal-position values less than 40 will
generally bury the figure within the horizontal blanking
area of the raster scan. That renders the figure virtually
invisible— which isn't necessarily an undesirable situation.
It is far easier to remove a figure from the screen by POKE-
ing into its horizontal-position register than it is to hide it
by any other means.
Vertical motion is generated by actually moving the fig-
ure through its own bit map. The bit map for a 2-line-per-
byte player figure is 128 bytes long. As described earlier,
that much RAM must be allocated for every player figure'
Few player figures will be that long, however, and the
space that remains is space that can be used for moving
the figure in the vertical directions.
254
That earlier discussion also implied that the top of a
figure should begin at the start of its bit-map area. That
isn't necessarily tHe case; but when a figure is located at
the top of its bit-map area, it will appear at the top of the
screen. Downward vertical motion is then achieved by
pushing the figure deeper into its bit-map area (into suc-
cessively higher RAM addresses).
Fig. 5-3 shows the memory maps for the overall player/
missile bit map. if you are using a 2-Iine resolution, the bit
map for player figure begins at a known address: the
starting address of the bit map (PMBASE) + 512. It is then
possible to move the figure downward by means of a rou-
tine that copies the bit map with successively higher
addresses.
That sort of vertical-motion operation can be rather
time consuming when run in BASIC, however, so it is gen-
erally considered a good practice to do the job with the
help of a simple machine-language move operation.
PLAYER/PLAYFIELD PRIORITIES
ATARI computers, with their special ANTIC graphics devi-
ces, make it rather easy to create the impression that one
object is moving behind or in front of another. There is a
priority-select register that lets you determine whether a
given figure has priority over, or will move in front of,
another figure on the screen.
That register is normally labeled GPRIOR, and it is
located at address 632. Table 5-7 shows the values that
should be POKEd to GPRIOR in order to establish the
orders of priority.
Executing a POKE 632,1 will give the player/missile fig-
ures priority over any playfield objects, and any playfield
objects will take priority over the background color.
255
Table 5-7. POKE Values for GPRIOR at Address 632
These Values Set the Priority of the Player, Missile, and
Playfield Figures
Value
Priorities
Player/missiles 0, 1, 2, and 3
PMield registers 0,1, 2, and 3
Background
Player/missiles and 1
Playfield registers 0, 1, 2, and 3
Player/missiles 2 and 3
Playfield registers 0, 1 , 2, and 3
Player/missiles 0, 1, 2, and 3
Background
Playfield registers and 1
Player/missiles 0, 1,2, and 3
Playfield registers 2 and 3
Background
Add 1 6— All four missiles take on the color specified at playfield regis-
ter 3; a condition often regarded as one that adds a fifth player to the
screen.
Add 32— Overlapping of player/missiles and 1 , or 2 and 3, will create
a third color in the overlapped region. Other combinations of over-
lapped figures will always show black in the overlapped region.
On the other hand, executing a POKE 632,8 will give any
playfield graphic that is plotted from color registers and
1 priority over all of the player/missile figures; but then all
player/missile figures will take priority over any playfield
graphic that is plotted from color registers 2 or 3. The
background, as usual, takes the lowest precedence.
It is important to recall that only the 4-color graphics
modes (Modes 3, 5, and 7) use all four playfield color
registers. Using the 2-color graphics modes limits the cap-
ability of this powerful animation and graphics tool.
256
COLLISION DETECTION
Yet another feature of the ATARI graphics system is a
built-in scheme for detecting a collision between figures.
The scheme not only detects a collision, but returns values
that indicate the kinds of figures involved.
There are 16 collision-detection registers and an addi-
tional register that is used for clearing them. Normally, a
program will clear the collision-detection registers and
then poll them from time to time to see whether or not
certain collision events have taken place. After some rele-
vant collisions have occurred, the program can take some
appropriate action and clear the registers once again.
The collision-status clearing register, HITCLR, is located
at address 53278; and POKEing any value greater than zero
will cause the system to clear the collision-detection
registers.
Table 5-8 summarizes the collision format for collisions
Table 5-8. Values Returned by PEEKIng Into
the Missile-to-Playfields Collision Registers
n
Collision Scenario
no collision since most recent HITCLR;
POKE 53278,255
1
Playfield from color register
2
Playfield from color register 1
3
Playfields from color registers and 1
4
Playfield from color register 2
5
Playfields from color registers and 2
6
Playfields from color registers 1 and 2
7
Playfields from color registers 0, 1 and 2
8
Playfield from color register 3
9
Playfields from color registers and 3
10
Playfields from color registers 1 and 3
11
Playfields from color registers 0, 1 , and 3
12
Playfields from color registers 2 and 3
13
Playfields from color registers 0, 2, and 3
14
Playfields from color registers 1 , 2, and 3
15
Playfields from color registers 0, 1 , 2, and 3
nPEEK(53248) for Missile-0 Collisions with Playfields
A7PEEK(53249) for Missile-1 Collisions with Playfields
nPEEK(53250) for Missile-2 Collisions with Playfields
nPEEK(53251 ) for Missile-3 Collisions with Playfields
257
between the missile figures and any playfield objects that
are plotted from color registers through 3. Whenever it
is necessary to see whether or not a collision has occurred
between missile figure 2 and a playfield object drawn from
color register 1, this sort of BASIC statement is in order:
IF PEEK 53250=2 THEN PRINT "BOOM"
Table 5-9 summarizes the same sort of information; but
in this case, the collision-detection operations refer to col-
lisions between player figures and playfield colors.
Table 5-9. Values Returned by PEEKing into
the Player-to-Playfields Collision Registers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Collision Scenario
nPEEK(53252)
nPEEK(53253)
nPEEK(53254)
nPEEK(53255)
no collision since most recent HITCLR;
POKE 53278,255
Playfield from color register
Playfield from color register 1
Playfields from color registers and 1
Playfield from color register 2
Playfields from color registers and 2
Playfields from color registers 1 and 2
Playfields from color registers 0, 1 , and 2
Playfield from color register 3
Playfields from color registers and 3
Playfields from color registers 1 and 3
Playfields from color registers 0, 1 , and 3
Playfields from color registers 2 and 3
Playfields from color registers 0, 2, and 3
Playfields from color registers 1 , 2, and 3
Playfields from color registers , 1 , 2, and 3
for Player-0 Collisions with Playfields
for Player- 1 Collisions with Playfields
for Player-2 Collisions with Playfields
for Player-3 Collisions with Playfields
Again, the same general format appears in Table 5-10.
The collisions in this instance, however, are between mis-
siles and players.
Tables 5-11 through 5-14 show the PEEK values that are
returned from registers that detect collisions between two
different player figures. The summary is divided into four
separate parts because a collision between a player figure
and itself is not a relevant, or even meaningful, situation.
258
Table 5-10. Values Returned by PEEKing Into
the Missile-to-Players Collision Registers
n
Collision Scenario
no collision since most recent HITCLR;
POKE 53278,255
1
Player
2
Player 1
3
Players and 1
4
Player 2
5
Players and 2
6
Players 1 and 2
7
Players 0, 1 , and 2
8
Player 3
9
Players and 3
10
Players 1 and 3
11
Players 0, 1 , and 3
12
Players 2 and 3
13
Players 0, 2, and 3
14
Players 1, 2, and 3
15
Players 0, 1 , 2, and 3
n=PEEK(53256) for Missile-0 Collisions with Players
/7=PEEK(53257) for Missile-1 Collisions with Players
n=PEEK(53258) for Missile-2 Collisions with Players
n=PEEK(53259) for Missile-3 Collisions with Players
Table 5-1 1 . Values Returned by PEEKing Into the
Player-to-Players Collision Registers
(Player to Players 1 , 2, and 3)
n
Collision Scenario
no collision since nnost recent HITCLR;
POKE 53278,255
2
Player 1
3
Player 1
4
Player 2
5
Player 2
6
Players 1 and 2
7
Players 1 and 2
8
Player 3
9
Player 3
10
Players 1 and 3
11
Players 1 and 3
12
Players 2 and 3
13
Players 2 and 3
14
Players 1 , 2, and 3
15
Players 1 , 2, and 3
/7PEEK(53260) for Player-0 Collisions with Players 1 , 2, and 3
259
Table 5-1 2. Values Returned by PEEKing Into the
Player-to-Players Collision Registers
(Player 1 to Players 0. 2, and 3)
n
Collision Scenario
no collision since most recent HITCLR;
POKE 53278,255
1
Player
3
Player
4
Player 2
5
Players and 2
6
Player 2
7
Players and 2
8
Player 3
9
Players and 3
10
Player 3
11
Players and 3
12
Players 2 and 3
13
Players 0, 2, and 3
14
Players 2 and 3
15
Players 0, 2, and 3
/7PEEK(53261)
for Player-1 Collisions with Players 0, 2, and 3
Table 5-13. Values Returned by PEEKing Into the
Player-to-Players Collision Registers
(Player 2 to Players 0. 1 . and 3)
n
Collision Scenario
no collision since most recent HITCLR;
POKE 53278,255
1
Player
2
Player 1
3
Players and 1
5
Player
6
Player 1
7
Players and 1
8
Player 3
9
Players and 3
10
Players 1 and 3
11
Players 0, 1, and 3
12
Player 3
13
Players and 3
14
Players 1 and 3
15
Players 0, 1 , and 3
/7=PEEK(53262) for Player-2 Collisions with Players 0, 1 , and 3
260
Table 5-14. Values Returned by PEEKIng Into the
Player-to-Players Collision Registers
(Player 3 to Players 0, 1 , and 2)
n
Collision Scenario
no collision since most recent HITCLR;
POKE 53278,255
1
Player
2
Player 1
3
Players and 1
4
Player 2
5
Players and 2
6
Players 1 and 2
7
Players 0, 1 , and 2
9
Player
10
Player 1
11
Players and 1
12
Player 2
13
Players and 2
14
Players 1 and 2
15
Players 0, 1 , and 2
/7PEEK(53264) for Player-3 Collisions with Players 0, 1 , and 2
261
Chapter 6
More About I/O Operations
A computer is useless without being able to perform
operations that let it accept data from other devices,
including the keyboard, and let it direct information to
other devices, including the display screen. Computer
users often take such operations for granted, but the
ATARI Operating System offers some fine opportunities
for redirecting the normal flow of information and,
indeed, creating new ones.
WORKING WITH THE PROGRAM RECORDER I/O
Chapter 1 describes the most commonly used techniques
for saving and loading tokenized BASIC programs at the
program recorder. The general idea is to execute CSAVE
and CLOAD commands or, alternatively, SAVE "C:" and
LOAD "C:" commands.
The following discussions extend the range of tech-
niques to include ATASCII-coded BASIC and pure data
files.
263
ATASCII-Coded BASIC Programs— LIST"C:" and
ENTER"C:"
The mechanical operations involved in saving and loading
BASIC programs that are saved in an ATASCII, or nontok-
enized, format are essentially the same as those already
described for tokenized programs. The only real differ-
ence is the nature of the commands.
To save an ATASCII-coded version of a BASIC program
on the program recorder, find the desired place on the
cassette tape and note the tape-counter reading.
Set the recorder to its record mode and enter this
command:
LIST "C:"
That will list the entire BASIC program, in the ATASCII-
coded format, to the program recorder. You know that
the operation is finished when the BASIC prompt symbol
and READY message reappear on the screen. Turn off the
program recorder at that time.
Alternatively, you can record selected portions of a
BASIC program that is resident in the system. This proce-
dure is especially helpful whenever you want to save some
commonly used subroutines for future programs. Where-
as the LIST "C:" command will save the entire program on
cassette tape, this command will list a portion of it:
LIST "C:", strtlinejastline
where strtline is the line number of the first line to be
recorded, and lastline is the final line number in the
segment.
The LIST command thus saves an ATASCII-coded ver-
sion of a BASIC program, or a selected portion of it, onto
cassette tape. The ENTER command is used for loading
that material back into RAM from the program recorder.
264
The mechanical procedures for using the ENTER com-
mand are quite similar to those for using the CLOAD
command. The ENTER command, however, must be used
with programs that were originally saved under the LIST
command.
First, enter this command at the ATARI console:
ENTER "C:"
The system will respond to that command by beeping the
console loudspeaker twice. That is the time to cue the
tape to the beginning of the AT ASCII-coded program you
want to load. After doing that, depress the PLAY lever on
the program recorder and strike any key on the ATARI
console (except the BREAK key). That will begin the load-
ing operation. The loading session is done when the
BASIC cursor and READY message reappear on the
screen.
The important advantage of the LIST/ENTER operations
is that they permit the merging of smaller program seg-
ments into a larger program in RAM. Recall that the LIST
program lets you specify selected portions of a program to
be saved on cassette tape. That is one difference. The big
difference, however, is that the ENTER command, unlike
its CLOAD counterpart, does not erase existing BASIC
programming from the system RAM; rather it adds the
previously saved routines to the existing program.
In the event that there are duplicate line numbers, the
most recently ENTERed segment will take precedence; in
effect, writing over lines of programming having the same
line numbers. When contemplating the use of these merg-
ing operations, it is thus very important to make sure that
the LISTed program line numbers will not duplicate
important program lines when you return them to the
system via the ENTER command.
Given some practice and some careful planning, it is
quite possible to use the LIST/ENTER commands to build
very large programs in a highly efficient fashion from rou-
tines that you developed and LISTed to the program
recorder at previous times.
265
The LIST and ENTER commands that refer to the pro-
gram recorder automatically select lOCB Channel 7. That
channel must not be open for any other purpose at the
time you execute either command.
Nonprogram Files— PRINT and INPUT
in the context of saving and loading information to the
program recorder, the PRINT and INPUT statements are
useful for working with files that are composed of infor-
mation other than lines of BASIC programming. Unlike
the program saving and loading operations, PRINT and
INPUT must be included in a program of their own — the
scheme cannot work directly from the keyboard.
The following example suggests a programming proce-
dure for a relatively simple data-recording operation:
10 OPEN #7,8,0,"C:"
20 FOR N=OTO 1000
30 PRINT #7,N;
40 NEXT N
Line 10 opens lOCB Channel 7 for output to the pro-
gram recorder, the FOR . . . NEXT loop generates the
numerical values for variable N, and line 30 outputs those
values to the program recorder.
Upon executing the OPEN statement in line 10, the sys-
tem will beep the console loudspeaker twice to signal the
time to set the program recorder to its RECORD mode
and strike any key (except the BREAK key) to begin the
recording operation.
The PRINT statement loads the values to the tape in
groups of 128; and you will notice a pause between each
group. Turn off the program recorder when the program
ends.
266
The example illustrates the fact that it is important to
open an iOCB channel prior to executing the PRINT
command. In this context, the general form of that OPEN
statement is
OPEN #chan,8,gap
where chan is the desired IOCB channel for the opera-
tion, and gap is a value of zero or 128. Setting gap to zero
causes the program recorder to pause while the system is
loading the next 128 bytes of data to the output buffer.
Setting gap shortens that interval, but risks inserting gar-
bage between successive segments of data on the cassette
tape.
The PRINT statement must specify the same IOCB
channel that is opened by the previous OPEN statement:
PRINT #chan, . . .
The following example suggests a way to reload the
numerals that were saved by the previous example of the
PRINT statement:
10 DIM X( 1000)
20 OPEN #7,4,0,"C:"
30 FOR N=0 TO 1000
50 NEXT N
Line 10 dimensions subscripted variable X, and line 20
opens IOCB Channel 7 for input from the program
recorder, using normal inter-record delays. Lines 30
through 50 then read the data from the cassette tape,
assigning each numerical value to the subscriped variable,
X.
Upon executing the OPEN statement, the system will
beep the console loudspeaker twice, thus signaling the
time to set the program recorder to the PLAY mode and
strike any key (except BREAK) to continue.
267
The PRINT and INPUT techniques work equally well
with string data and, indeed, combinations of numerical
and string data. It is absolutely necessary, however, to
make certain that the variable names are organized such
that there is no type mismatch anywhere through the sav-
ing and loading routines.
Nonprogram Files— PUT and GET
BASIC'S PUT and GET statements offer an alternative
means for working with file data. Unlike PRINT and
INPUT, however, PUT and GET operations are limited to
numerical values (although strings can be converted to
ATASCII codes before they are PUT to the program
recorder. But generally speaking, the PUT/GET routines
are quite similar to the PRINT/INPUT routines just
described.
The following example suggests a programming proce-
dure for a relatively simple data-recording operation:
10 OPEN #7,8,0,'C:"
20 FOR N=0 TO 1 000
30 PUT #7,N
40 NEXT N
Line 10 opens lOCB Channel 7 for output to the pro-
gram recorder, the FOR . . . NEXT loop generates the
numerical values for variable N, and line 30 outputs those
values to the program recorder.
Upon executing the OPEN statement in line 10, the sys-
tem will beep the console loudspeaker twice to signal the
time to set the program recorder to its RECORD mode
and strike any key (except the BREAK key) to begin the
recording operation.
The PUT statement loads the values to the tape in
groups of 128; and you will notice a pause between each
group. Turn off the program recorder when the program
ends.
268
As with the PRINT-recording technique, an lOCB chan-
nel must be opened for output to the program recorder
before the PUT operations begins:
OPEN #c/ian,8,gap
where chan is the desire lOCB channel for the operation,
and gap is a value of zero or 128 for the purpose described
for the PRINT/INPUT operations.
The subsequent PUT statement must specify the same
lOCB channel that is opened by the OPEN statement:
PUT #chan,x
where chan is the IOCS channel number and x is any
numeric variable, constant or expression.
The following example suggests a way to reload the
numerals that were saved by the previous example of the
PUT statement:
10 DIM X( 1000)
20 OPEN #7,4,0, "C:"
30 FOR N=0TO 1000
40GET#7,X(N)
50 NEXT N
Line 10 dimensions subscripted variable X, and line 20
opens lOCB Channel 7 for input from the program
recorder, using normal inter-record delays. Lines 30
through 50 then read the data from the cassette tape,
assigning each numerical value to the subscripted varia-
ble, X.
Upon executing the OPEN statement, the system will
beep the console loudspeaker twice, thus signaling the
time to set the program recorder to the PLAY mode and
strike any key (except BREAK) to continue.
It is possible to use the PUT/GET operations with string
data if the strings are first converted to their ATASCII
codes.
269
WORKING WITH THE DISK DRIVE I/O
Chapter 1 describes the most commonly used techniques
for saving and loading tokenized BASIC programs on a
diskette by means of SAVE "D:" and LOAD "D:" com-
mands, respectively.
The following discussions extend the range of tech-
niques to include ATASCIi-coded BASIC and pure data
files.
ATASCii-Coded BASIC Programs— LIST"D:" and
ENTER'D:"
The mechanical operations involved in saving and loading
BASIC programs that are saved in an ATASCII, or nontok-
enized, format are essentially the same as those described
for tokenized programs. The only real difference is the
nature of the commands.
Use a command of this form to save an ATASCII-coded
version of a BASIC program on a selected disk drive
system:
LiST"D[n] :ft/ename[.ext]"
That will list the entire BASIC program to disk-drive n
under the name, filename, and with an optional exten-
sion, ex(. See the previous discussion for general rules
regarding the selection of filenames and extensions.
Example:
LIST"D:SILLY.FUN"
That LIST command will use the default disk drive (usually
drive #1) for saving an entire BASIC program—
SILLY.FUN- in an ATASCII-code format.
270
Alternatively, you can record selected portions of a
BASIC program that is resident in the system. This proce-
dure is especially helpful when you want to save some
commonly used subroutines for future programs. Where-
as the previous saves the entire program, this form of the
command saves a selected portion of it:
LIST"D[n]:ft/ename[.ext]"^frt//ne,/ast//ne
where strtline is the line number of the first line to be
recorded, and lastline is the final line number in the
segment.
Example:
LIST"D:M1XER ",200,300
That command will save the BASIC programming between
lines 200 and 300, inclusively, on the default disk drive
under the name MIXER.
The ENTER command is used for loading ATASCII-
coded BASIC programs that were originally saved with the
LIST command. The general form of the command is;
ENTER"D[n ] -.filename [.ext ]"
The important advantage of the LIST/ENTER operations
is that they permit the merging of smaller program seg-
ments into a larger program in RAM. Recall that the LIST
program lets you specify selected portions of a program to
be saved on a diskette. That is one difference. The big
difference, however, is that the ENTER command, unlike
its SAVE counterpart, does not erase existing BASIC pro-
gramming from the system RAM; rather it adds the pre-
viously saved routines to the existing program.
271
In the event that there are duplicate line numbers, the
most recently ENTERed segment will take precedence; in
effect, writing over lines of programming having the same
line numbers. When contemplating the use of these merg-
ing operations, it is thus very important to make sure that
the LISTed program line numbers will not duplicate
important program lines when you return them to the
system via the ENTER command.
Given some practice and some careful planning, it is
quite possible to use the LIST/ENTER commands to build
very large programs in a highly efficient fashion from rou-
tines that you developed and LISTed on a diskette at pre-
vious times.
Nonprogram Files— PRINT and INPUT
In the context of saving and loading information to a
selected disk drive, the PRINT and INPUT statements are
useful for working with files that are composed of infor-
mation other than lines of BASIC programming. Unlike
the operations for saving and loading BASIC programs,
PRINT and INPUT must be included in a program of their
own — the scheme cannot work directly from the key-
board.
The following example suggests a programming proce-
dure for a relatively simple data-recording operation:
10 OPEN #7,8,0, "D:NUMBERS.FIL"
20 FOR N=0 TO 1 000
30 PRINT #7,N;
40 NEXT N
Line 10 opens lOCB Channel 7 for writing a new pro-
gram to the default disk drive under the name NUMBERS.
FIL. The FOR . . . NEXT loop generates the numerical
values for variable N, and line 30 outputs those values to
the program recorder.
Upon executing the OPEN statement in line 10, the disk
drive will begin running, and it will continue running until
the saving routine is completed.
272
The example illustrates the fact that it is important to
open an iOCB channel prior to executing the PRINT
command. In this context, the general form of the OPEN
statement is
OPEN ^chan, task, 0,"D -Jilename"
where chan is the desired IOCB channel for the operation
and task defines the exact nature of the disk operation. It
is possible to specify an alternate disk drive, Dn, and assign
an extension to the filename. There are two different task
assignments that are useful for PRINT operations:
Write a new file — 8
Append an existing file — 9
The example suggests a task value of 8 so that NUM-
BERS.FIL will be opened as a new file. You can add data to
an existing file, though, by using a task value of 9.
The PRINT statement must specify the same IOCB
channel that is opened by the previous OPEN statement:
PRINT #chan, . . .
The following example suggests a way to reload the
numerals that were saved by the previous example of the
PRINT statement:
10 DIM X( 1000)
20 OPEN #7,4,0, "D:NUMBERS.FIL"
30 FOR N=0TO 1000
40 GET#7,X(N)
50 NEXT N
Line 10 dimensions subscripted variable X, and line 20
opens IOCB Channel 7 for reading data from a disk file
named NUMBERS.FIL. Lines 30 through 50 then read the
data from that file, assigning each numerical value to the
subscripted variable, X.
273
The PRINT and INPUT techniques work equally well
with string data and, indeed, combinations of numerical
and string data. It is absolutely necessary, however, to
make certain that the variable names are organized such
that there is no type mismatch anywhere through the sav-
ing and loading routines.
Nonprogram Files— PUT and GET
BASIC'S PUT and GET statements offer an alternative
means for working with file data. Unlike PRINT and
INPUT, however, PUT and GET operations are limited to
numerical values (although strings can be converted to
ATASCII codes before they are PUT to the program
recorder). But generally speaking, the PUT/GET routines
are quite similar to the PRINT/INPUT routines just
described.
The following example suggests a programming proce-
dure for a relatively simple data-recording operation:
10 OPEN #7,8,0, "D:NUMBERS.FIL"
20 FOR N=0TO 1000
30 PUT#7,N
40 NEXTN
Line 10 opens lOCB Channel 7 for writing a new file to
the default disk drive. The FOR . . . NEXT loop generates
the numerical values for variable N, and line 30 outputs
those values to the disk.
As with the PRINT-recording technique, an lOCB chan-
nel must be opened for output to the program recorder
before the PUT operation begins. The PUT statement must
then specify the same lOCB channel number. The general
form of PUT statement is:
PUT #chan,x
where chan is the lOCB channel number and x is any
numeric variable, constant, or expression.
274
The following example suggests a way to reload the
numerals that were saved by the previous example of the
PUT statement:
10 DIM X( 1000)
20 OPEN #7,4,0,"D:NUMBERS.FIL"
30 FOR N=OTO 1000
40 GET #7,X(N)
50 NEXT N
Line 10 dimensions subscripted variable X, and line 20
opens lOCB Channel 7 for reading data from a disk file
named NUMBERS.FIL. Lines 30 through 50 then read the
data from the cassette tape, assigning each numerical
value to the subscripted variable, X.
It is possible to use the PUT/GET operations with string
data if the strings are first converted to their ATASCII
codes with the help of the ASC or ADR functions.
SAVING, LOADING, AND RUNNING BINARY FILES
UNDER DOS
Chapter 1 describes most of the DOS operations that can
be conducted directly from the DOS menu. The idea is to
bring up the menu by entering the DOS command from
BASIC, select one of the menu options, and then follow
the prompting messages from there. Returning to BASIC is
a matter of selecting DOS menu option B (assuming that
the BASIC cartridge is installed) or by striking the SYSTEM
RESET key.
It was not appropriate to describe the three DOS menu
options that deal with binary, or machine-language, files.
This is a better place to deal with that matter.
275
Saving Binary Programs and Data
The DOS menus for both versions, 1.0 and 2.0S, show
BINARY SAVE as option K. They both accomplish the same
task— saving specified block of binary-coded information
on disk— but the mechanical procedures are somewhat
different.
Under DOS version 1.0, selecting the K option brings up
this prompting message:
SAVE-GIVE FILE,START,END
The system is expecting you to enter, in turn, a filename,
tiie start address of the data to be saved, and the last
address. Both addresses must be entered in a hexadecimal
format.
When the data is loaded back into the computer at
some later time, you can have things arranged so that it
will begin execution immediately. The procedure requires
several steps, but the results can be quite satisfying Before
executing the DOS command to see the menu, POKE a
2-byte binary version of the starting address of the
machine-language routine into RAM addresses 736 and
737— LSB followed by MSB. Then execute the DOS com-
mand, and select menu item K. Respond to the prompting
message as before, but this time append the filename with
/A. The latter step, along with setting the starting address
into locations 736 and 737, will save the starting address on
the disk as well as the machine-language routine, itself.
Having done that, electing menu option L will not only
load the program, but begin running it immediately.
Matters are somewhat simple when saving binary files
under DOS 2.0S. Upon selecting option K, you see this
prompting message:
SAVE-GIVE FILE,START,END[,INIT,RUN]
276
Your first series of entries should be a filename, a starting
address and an ending address — both addresses using a
hexadecimal format. If you choose to ignore the portion
of the prompting message that is enclosed in brackets,
there will be no automatic run when the program is
loaded at some later time.
Responding with hexadecimal addresses in the INITand
RUN locations will allow the system to begin execution of
the machine-language routines the moment it is loaded
under DOS menu item L.
INIT is the starting address of the first of two possible
machine-language routines; and if that routine concludes
with an RTS, the system will then begin execution at the
address specified by RUN.
If INIT and RUN happen to have the same address, only
INIT need be specified when the program is saved. In any
event, include the commas, but do not include the brack-
ets in your entry. .
Loading and Running Binary Programs
Electing DOS menu option L, BINARY LOAD, will bring up
this prompting message:
LOAD FROM WHAT FILE?
Respond with a valid filename of a binary program that
was saved at some earlier time. If the program was saved in
a fashion that forces the system to run it immediately, it
will do so. Otherwise, you must elect DOS menu item M.
Selecting item M, RUN AT ADDRESS, you see this
prompting message:
RUN FROM WHAT ADDRESS?
Respond by entering the starting address of the binary
program. The entry must be in a hexadecimal format.
277
OPENING AND CLOSING lOCB CHANNELS
The ATARI Operating System has eight separate channels
that are organized into I/O control blocks, or lOCBs. One
is fully dedicated to the normal screen/keyboard opera-
tions, and two others are automatically opened and dosed
as the operating system dictates. The remaining five lOCBs
are free for custom applications. Table 6-1 summarizes the
iOCB channels and their allocation.
The operating system automatically closes all channels,
except Channel 0, during its normal start-up routine. In
order to use one of the channels, then, you must execute
a statement that opens it; and there are two BASIC state-
ments that can serve that purpose:
OPEN #c/ian,(as/c,aux7,"dev"
and
XIO 3,#chan,tas/c,aux7,"c/ev"
where chan is the IOCB channel to be opened, task is a
code number representing a task to be performed, aux7 is
a code number for a secondary task description, and dev is
a device-type specifier.
Table 6-1. Summary of IOCB Channels
and Their Allocation
Channel
2
3
4
5
6
Allocation
Always open for screen editor (E:)
Free to use
Free to use
Free to use
Free to use
Free to use
Automatically opened and closed for
graphics operations
Automatically opened and closed for
I/O operations to a program recorder
or disk drive
278
Chart 6-1 summarizes the device types that can be speci-
fied for I/O operations. Notice that the specifiers must
end with a colon.
Chart 6-1 . Summary of lOCB Device Types, Dev
Device-Name Expressions
Program recorder
C:
Disk drive
D[n]:filename[.ext]
Where n is the optional drive number (1-4)
filename is a mandatory filename
.ext is an optional filename extension
Filenames can be composed of up to eight letters and numer-
als, but must begin with a letter.
Extensions can be composed of up to three letters and numer-
als, but must be preceded with a period.
Examples:
D:FOAM References filename FOAM on the only disk
drive connected to the system.
D2:RATS.BAS References filename RATS with extension
BAS on disk drive 2.
NOTE:DOS must be booted in order to use this device expression.
Screen Editor
E:
Console Keyboard
K:
ATARI Printer
P:
RS-232 Serial Port
R[/7]:
Where n is the serial-port number (1 -4 if used with the 850
serial interface module). Omitting n implies serial
port 1 .
NOTE: The serial device handler, loaded through AUTORUN.SYS,
must be resident in memory before this device expression
can be used.
Video Screen
S:
279
Table 6-2 first lists the general task codes and then cites
some examples that apply to particular devices
Obviously, not all possible tasks apply equally well to al!
types of devices. A write, or output, operation to the pro-
gram recorder is a meaningful task, but that sort of opera-
tion has no meaning at all for keyboard operations.
Table 6-2. Summary of lOCB Task Codes for
BASIC'S OPEN Statement
General Task Codes
1 Append
2 Disk operation
4 Input
8 Output
16 Text-window flag
32 No screen clear
Examples:
12 input/Output task
9 Output with append
6 Read disk directory
Task Code
Useful Program-Recorder Tasks
Operation
4
8
Task Code
4
6
8
9
Task Code
8
9
12
13
Task Code
Read from program recorder
Write to program recorder
Useful Disk-File Tasks
Operation
Read from disk
Read disk directory
Write new file to disk
Append disk file
Useful Screen-Editor Tasks
Operation
Write to screen
Append screen
Keyboard input/screen output
Screen input and output
Useful Keyboard Task
Operation
Read from keyboard
280
Table 6-2— cont. Summary of lOCB Task Codes for
BASIC'S OPEN Statement
Useful Printer Task
Task Code
Operation
8
Write to printer
Useful RS-232 Port Tasks
Task Code
Operation
4
Block read
5
Concurrent read
8
Write entire block
9
Concurrent write
13
Concurrent read and write
Useful Screen Tasks
Task Code
Operation
8
Clear the screen, use no text window,
and allow write only
12
Clear the screen, use no text window.
and allow both read and write
24
Clear the screen, use a text window, and
allow write only
28
Clear the screen, use a text window, and
allow both read and write
40
Do not clear the screen (except Mode 0),
use no text window, and allow write only
44
Do not clear the screen (except Mode 0),
use no text window, and allow both read
and write
56
Do not clear the screen (except Mode 0),
use a text window, and allow write only
60
Do not clear the screen (except Mode 0),
use a text window, and allow both read
and write
The auxl parameter in the OPEN and XIO statements
refer to device-specific operations. There is nothing gen-
eral about them. Table 6-3 indicates the auxl codes as they
apply to the various device types. Notice that the value is
normally zero, with the notable exception of display-
screen applications.
281
Table 6-3. Summary of Device-Specific Aux 1
Codes for BASIC'S OPEN Statement
Code
128
Code
83
Code
1
2
3
4
5
6
7
8
For Program Recorder
Operation
Normal inter-record delay
Short inter-re cord delay
For Disk Drive
Always
For Screen Editor
Always
For Keyboard
Always
For ATARI Printer
Operation
Normal printing
Sideways printing (ATARI 820 only)
RS-232 Ports
Always
For Display Screen
Operation
BASIC Mode-0 screen
BASIC Mode-1 screen
BASIC Mode-2 screen
BASIC Mode-3 screen
BASIC Mode-4 screen
BASIC Mode-5 screen
BASIC Mode-6 screen
BASIC Mode-7 screen
BASIC Mode-8 screen
Consider this OPEN statement:
OPEN #2,4,0,K.
That statement literally says: open lOCB Channel 2 for
reading operations from the keyboard. An equivalent XiO
version of the same thing is:
XIO 3,#2,4,0,K:
282
After executing either of those statements, you can fetch a
character from the keyboard by executing INPUT #3,
numvar or GET #3, numvar; where numvar will take on the
ATASCil code of the current keystroke.
The operating system normally uses lOCB Channel 6 for
the screen, but you can open another channel for graph-
ics operations:
OPEN #4,40,4,5:
That happens to open iOCB Channel 4 for a version of
screen Mode 4 that does not clear and has no text
window.
Although the operating system automatically closes all
opened channels when it successfully comes to an end, it
is a good idea to keep things tidy by closing the channels
you use when you are through with them. There are two
ways to go about doing that:
CLOSE #chan
XIO 12,#chan,0,0,"dev"
USING THE XIO COMMAND
The XIO command is one of the most powerful of ATARI
BASIC'S commands. It can be a rather complicated com-
mand, but it can be used for setting up virtually any kind
of I/O task through the ATARI system's available I/O con-
trol blocks.
The previous section in this chapter demonstrated the
fact that properly formatted XIO commands can replace
the OPEN and CLOSE commands. A brief look at Table 6-4
shows that it can simulate a lot of other l/O-related BASIC
commands.
The XIO command has this general syntax:
XIO cmd,#chan,aux7,aux2,"dev"
283
where chan and dev are identical to their counterparts in
the OPEN statement, and Table 6-4 shows the cmd code
and their meaning.
Table 6-4. Summary of XIO Commands, CMD
Code
3
5
7
9
11
12
13
17
18
Code
32
33
35
36
37
38
254
Code
32
34
36
38
40
For General Operations
Operation
Open a channel
Input a line
Input a character
Output a line
Output a character
Close a channel
Get current lOCB status
Draw a line (graphics)
Fill an area (graphics)
BASIC Equivalent
OPEN
INPUT
GET
PRINT
PUT
CLOSE
STATUS
DRAWTO
none
For Disk Operations
Operation
Rename a file
Delete a file
Lock a file
Unlock a file
Move the file pointer
Find the file pointer
Format a disk
BASIC Equivalent
DOS menu item E
DOS menu item D
DOS menu item F
DOS menu item G
POINT
NOTE
DOS menu item I
For RS-232 Serial Operations
Operation
Output short block
Set outgoing lines DTP, RTS, and XMT
Set baud rate, word size, stop bits, and
ready monitoring
Set translation modes and parity
Start concurrent I/O mode
The aux7 and aux2 parameters are set to under all but
the following XIO commands: XIO 3, XIO 34, XIO 36 and
XIO 38. The XIO 3 command simulates the OPEN state-
ment, using OPENS task and auxl arguments (Chart 6-1
and Table 6-2) for XIO's auxl and aux2, respectively This
chapter concludes with descriptions of the special argu-
ments for XIO 34, XIO 36 and XIO 38
284
Controlling Outgoing Lines With XIO 34
The ATARI 850's serial output can be configured for Data
Terminal Ready (DTR), Request To Send (RTS) and data
Transmit (XMT) lines. Serial can handle all three, ports 2
and 3 have the DTR and XMT options, while port 4 has
only XMT.
The general form of the XIO 34 command thus looks
like this:
XIO 34,#chan,aux7,0/'R[n]:"
where chart is the lOCB that is handling the data, and n is
the serial port number. The aux1 argument determines
the DTR/RTS/XMT configuration as summarized in Table
6-5.
Table 6-5. XIO 34 Aux 1 Values. Set
Aux 2 to in All Instances
DTR
RTS
XMT
Code
Off
Off
Off
162
Off
Off
On
163
Off
On
Off
178
Off
On
On
179
On
Off
Off
226
On
Off
On
227
On
On
Off
242
On
On
On
243
Configuring Baud Rate. Word Size, and Stop Bits With
XIO 36
The XIO 36 statement must be used for specifying serial-
port operations with regard to the number of stop bits, the
word size, transmission baud rate, and incoming-signal
tests.
The general form of this XIO statement is
XIO 36,#chan,aux7,aux2,"R[n]:"
285
Table 6-6 shows the values for aux7 that are to be
derived by summing one value from each of the three
columns, if, for example, you are configuring the port of 1
stop bit (value = 0), a 7-bit word size (value = 16) and a
baud rate of 1200 (value = 10), the final value of (aux7) is
+ 16 + 10 = 26.
The aux2 argument sets the tests performed on the
incoming signal. The options are Data Set Ready (DTS),
Clear to Send (CTS), Carrier Detect (CRX), or any combi-
nation of them. Table 6-6 also summarizes the values that
correspond to those testing features.
Setting Translation Modes and Parity with XiO 38
The XIO 38 command handles two rather independent
features of the RS-232 scheme. One feature exploits the
fact that the 850 and serial device handler can send and
receive data of opposite or like parity. See the input and
Output Parity columns in Table 6-7.
The second feature expressed by the XIO 38 command
has to do with the unusual character coding scheme for
the ATARI system. As long as you are communicating
between ATARI systems, the built-in ATASCII coding
causes no problems; and there is no need for an append-
ed line feed nor any translation. But the differences
between standard ASCII and ATASCII can become trou-
blesome when communicating between an ATARI system
and another device that uses standard ASCII coding. The
purpose of the translation feature is to smooth out the
significant differences.
286
Table 6-6. XIO 36 Values for Aux 1 and Aux 2
aux 1
Stop
Bits
Value
Word
Size
Value
Baud
Rate
Value
1
8
300
2
128
7
16
45.5
1
6
32
50
2
5
48
56.875
75
110
134.5
150
300
600
1200
1800
2400
4800
9600
9600
3
4
5
6
7
8
9
10
11
12
13
14
15
i
iux2
DSR
CTS
CRX
Value
No
No
No
No
No
Yes
1
No
Yes
No
2
No
Yes
Yes
3
Yes
No
No
4
Yes
No
Yes
5
Yes
Yes
No
6
Yes
Yes
Yes
7
Table 6-7. XIO 38 Values for Aux 1 . Set Aux 2
to Zero Unless Using the Heavy Translation Mode
Line Feed
Translation
Input Parity
Output Parity
No
Yes 64
Light
Heavy 1 6
None 32
Ignore
Odd 4
Even 8
Ignore 1 2
Same
Odd 1
Even 2
Bit on 3
The values shown in each of the four columns in Table
6-7 should be selected and summed to arrive at a final
value for aux7 in the XIO 38 command.
287
Working under light translation, the system changes the
EOL character to the standard CR and sets the most-
significant bit of each ATASCII code to zero. The result is
something that is quite close to standard ASCII. As far as
incoming data is concerned, the standard ASCII CR char-
acter is translated to the ATARI system's equivalent, EOL,
and the most-significant bit of each character code is
ignored.
Under the heavy-translation transmission, a light trans-
lation is performed, but then only those ATASCII charac-
ters that correspond directly to equivalent ASCII codes are
sent. And during the input operations, the system changes
ASCII's CR character to EOL, passes those characters
whose ASCII and ATASCII codes are identical. If the codes
aren't identical, the system substitutes the ATASCII char-
acter code that is specified by the aux2 parameter of the
XIO 38 command.
288
chapter 7
A Miscellany of Principles and
Procedures
whenever authors and editors are organizing a book of
this sort, it seems that there are always a few topics that do
not fit neatly into the overall presentation. That has been
the case with this book, and the purpose of this chapter is
to discuss some of those topics.
MORE ABOUT THE SOUND FEATURES
The ATARI system's sound features are about as unique in
the world of personal computing as its color graphics fea-
tures are. For a programmer with the proper interest and
motivation, the sound features offer a wealth of fascinat-
ing opportunities — from renditions of 4-part musical
scores to complex sound effects.
Working under ATARI BASIC, the SOUND statement
can select one of four voices, or sound channels, set the
pitch of the sound, the amount of distortion and the
loudness for the selected voice. It is possible to work with
all four voices simultaneously; and all of that sound is
reproduced at the loudspeaker in the tv receiver or
monitor.
289
The SOUND Statement
ATARI BASIC'S SOUND statement has this general syntax:
SOUND voice,pitch,di5tjVolume
where voice is the sound channel (0 through 3) being
addressed, pitch is the frequency code (0 is highest and
255 is lowest), dist is an even-numbered distortion value (0
for maximum noise, or distortion, and 14 for pure tones),
and volume is the volume level (0 for no sound, and 15 for
maximum loudness).
The SOUND statement does not include any provisions
for determining the duration of the sound; once a
SOUND statement is executed, it produces its specified
sound until some other action causes it to change or stop.
In fact, it is sometimes more troublesome to stop a sound
than it is to initiate it. If a short SOUND program includes
no provisions for turning off the sounds and it does not
conclude with an END statement, the system will continue
generating the prescribed sounds even after the program
is done. One way to silenc e the system in that case is to
strike the MfiHAMMaB key. Or better, yet, conclude
the program with an END statement.
There are some other BASIC statements that automati-
cally silence any sound: CLOAD, CSAVE, DOS, ENTER,
LOAD, NEW, RUN and SAVE. The most elegant way to
silence a particular voice, however, is by specifying zeros
for the tone, distortion and volume parameters in its
SOUND statement. The following program plays a particu-
lar sound from voice for a short period of time, then
silences that voice before coming to an end.
10 SOUND 0,193,14,12
20 FOR D=0TO lOOiNEXTD
30 SOUND 0,0,0,0
Fig. 7-1 relates some of the tone values to an ordinary
musical scale. The figure is most helpful when you want to
reproduce music that is already printed on a score.
290
29 31 33 35 37 40 42 45 47 50 53 57 60
(C) (B) B^) (A) (Q») (Q) (F*) (F) (E) (E'') P) (C*) (C)
f ^ r r^
64 68 72 76 81 85 91 96 102 108 114 121
(B) (BW (A) (At) (G) (F#) (F) (E) (Ek) (D) (C») (C)
128 136 144 153 162 173 182 193 204 217 230 243
(B) (Bb) (A) (G») (G) (F») (F) (E) (E>) (D) (C#) (C)
Fig. 7-1 . The tone values as they relate to a musical scale.
Here is a routine tliat sets up some "barbershop"
harmony:
10 SOUND 0,121, 14,12:G0SUB 60
20 SOUND 1,96,14,12:G0SUB 60
30 SOUND 2,81,14,12:GOSUB 60
40 SOUND 3,60,1 4,1 2;G0SUB 60
50 GOSUB 60:END
60 FOR D=1 TO 200:NEXT D:RETURN
Or if you want a single voice to play those four notes in
succession:
10 SOUND 0,121, 14,12:GOSUB 60
20 SOUND 0,96,14,1 2.G0SUB 60
30 SOUND 0,81, 14,12:G0SUB 60
40 SOUND 0,60,14,1 2:G0SUB 60
50 GOSUB 60:END
60 FOR D=1 TO 200.NEXT D:RETURN
291
Clearly, the duration of sounds and their timing must be
handled by separate timing statements, usually FOR
NEXT loops.
Reproducing Musical Scores
Reproducing simple musical scores is a straightforward
procedure. As long as all voices are playing notes of the
same duration, it is a simple matter of setting up the
SOUND statements and executing them for appropriate
periods of time.
But matters become more complicated when dealing
with scores calling for controlling notes of different dura-
tion simultaneously. There are a number of workable ways
to approach that situation, but perhaps the most dynamic
is to apply a multitasking technique. The general idea is to
write a separate musical subroutine for each voice, and
then use ON . . . GOSUBstatements to cycle through the
subroutines until the composition is finished.
Unfortunately, it is beyond the intended scope of this
book to pursue that idea any further. It has to be enough
to say that anyone with an understanding of program mul-
titasking and the basic principles of music can reproduce
compositions of complexity and duration that are limited
only by one's patience and creative ability. (RAM capacity
is not a serious obstacle if you use some linking tech-
niques to load new segments of programming from a disk
as the composition progresses.)
Experimenting With Sound Effects
Whereas it is possible to reproduce musical compositions
from a score, matters are not so clearly defined for gener-
ating sound effects. Achieving a desired sound is more a
matter of triai-and-error experimentation than anything
else. A few general principles can guide your work,
however.
292
The distortion parameter can be especially important
for sound effects. A bit of experimenting with that
parameter, alone, can give you a good feeling for its
effects.
Then, too, it is often desirable to create certain sounds
by combining two or more voices. Few other brands of
personal computers offer that advantage.
The duration of events is, of course, determined by tim-
ing loops.
Finally, it can be instructive to work with some attack
and decay routines. The general idea is to fit a SOUND
statement within a FOR . . . NEXTloop that increments or
decrements a variable for the loudness parameter.
MORE ABOUT THE USR FUNCTION
The USR function is ATARI BASIC'S route into machine
language programs. In its simplest form, the USR function
has this syntax:
var = USR(addr)
That function initiates the execution of a machine lan-
guage program that begins at address addr. A numerical
variable, var is meaningless — a "dummy" variable — in this
simple context.
The USR function initiates a jTriachine language routine,
and an RTS instruction at the conclusion of that routine
returns the system to BASIC once again.
Fig. 7-2 shows how the simplest kind of USR function
affects the 6502 stack. Prior to executing the USR state-
ment, the stack contains undetermined data that is related
to the operation of the system (Fig. 7-2A). Immediately
after executing a simple USR function, the computer
pushes the BASIC return address and the number of vari-
ables in the function to the stack. In this simple case, there
are no variables being passed; but nevertheless, that byte
of data appears on the top of the stack. See Fig. 7-2B.
293
TOP OF
STACK
TOP OF
STACK
1 BYTE
2 BYTES^JI'g^g^
CURRENT
CONTENTS
NO. OF VALUES
BASIC RETURN
ADDRESS
(A) Stack prior to executing USR.
MSB I 2
LSB I BYTES
(B) Stackjust after executing the
USR.
(C) The necessary condition of
the stack before using an
RTS statement to return to
BASIC.
Fig. 7-2. The system stack under the simplest kinds of USR
commands.
Before returning to BASIC by executing a machine-
language RTS instruction, you must use a PLA instruction
to pull that number-of-variables byte off the stack. Fig.
7-2C shows how the stack should appear before executing
the RTS instruction.
Thus, any USR statement of this simple form:
var == USR(addr)
must call a machine-language routine that ends with these
two instructions:
PLA ;Pull no. of variables off the stack
RTS ;Return to BASIC
The following BASIC program first POKES the two-
instruction machine code into addresses 1536 and 1537,
and then it uses a USR function to execute it.
294
10 POKE 1 536, 1 04:POKE 1 537 96
20 A=USR(1536)
An assembly language version of that two-instruction rou-
tine looks like this:
1536 104 PLA ;Pull no. of variables from stack
1537 96 RTS ;Return to BASIC
It is a do-nothing routine, but it does illustrate the need
for pulling the number-of-values byte off the stack before
executing the RTS instruction.
The next program uses a machine language routine to
print the ATARI character set, including the inverse ver-
sions, along the top of the screen:
10 FORN=1536TO 1549
20 READ X:POKE N,X
30 NEXT N
40 GRAPHICS
50 POSITION 0,15
60 A=USR(1536)
70 DATA 162,0,138,157,64,156
80 DATA 232,138,201,128,208,246
90 DATA 104,96
An assembly language rendition of the routine that is
POKEed into addresses 1536 through 1549 looks like this:
1536 162
LDX#0
;Zero the X register
1538 138
TXA
;Transfer X to A
1539 157
64
156 STA40000,X;PlotAtothe
screen
1542 232
INX
increment X
1543 138
TXA
;Transfer X to A
1544 201
128
CMP#128
;Counting done?
1546 208
246
BNE-10
;lf not, plot again
1548 104
PLA
;Get rid of no. var.
1549 96
RTS
;Returnto BASIC
295
Passing Values to a Machine Routine
The USR function includes provisions for passing any
number of numerical values to a machine language rou-
tine. The general syntax in this case is:
var = USR(ac/clr,expr)
where addr is the starting address of the machine lan-
guage programming, expr is a numeric value or expres-
sion to be passed to the machine language routine, and
var is (in this context) a "dummy" variable. The value of
expr must be a positive integer between and 65536.
The value is passed to the machine language routine
through the 6502 stack, and Fig. 7-3 shows how the stack
appears before the USR function is executed, immediately
after the function is executed, and how it should appear
just prior to executing the RTS instruction to return to
BASIC.
Notice from the diagram that the number-of-values
byte appears on the top of the stack. After that comes the
MSB of the value expr, followed by the LSB of expr. The
return address of the BASIC program is the final item in
the stack.
NOTE: The MSB of a value passed to a machine language
routine appears on the stack before its LSB does.
The value that is passed to the stack is thus buried under
the number-of-values byte; so in order to do anything
useful with the value, the machine language routine must
first execute a PLA to get rid of that byte. Then the value-
MSB followed by LSB— is available via two more PLA
instructions.
The following BASIC program first POKEs a machine
language routine into addresses 1536 through 1543. It then
prompts the user to enter a positive integer between and
65536, executes an INPUT statement to assign the value to
variable N, and then executes a USR function that both
initiates the routine and passes the value of N to it.
296
TOP OF
STACK
1 BYTE
TOP OF
STACK
2 BYTES
2 BYTES
CURRENT
CONTENTS
MSB
LSB
MSB
LSB
NO. OF VALUES
VALUE PASSED
BASIC RETURN
ADDRESS
(A) Stack prior to executing USR.
(C) The necessary condition of
the stack before using an
RTS statement to return to
BASIC.
(B) Stack just after executing the
USR.
Fig. 7-3. The system stack when passing a single variable under USR
commands.
The program returns to BASIC at line 90 where it prints a
pair of values from zero-page memory addresses 203 and
204. And what you see there is a 2-byte decimal version of
the value assigned to N.
297
10 FOR N=1536TO 1543
20 READ D:POKE N,D
30 NEXT N
50 GRAPHICS
60 PRINT "ENTER A POSITIVE INTEGER VALUE
(0-65536)"
70 INPUT N
80 X=USR(1536,N)
90 PRINT PEEK(203) ,PEEK{204)
100 DATA 104,104,133,204,104,133,203,96
The assembly version of the machine language routine
looks like this:
1536 104 PLA ;Throw away no. of
vals. byte
1537 104 PLA ;FetchMSBofN
from stack
1 538 1 33 204 STA 204 ;Store it in 204
1540 104 PLA ;FetchLSBofN
from stack
1541 133 203 STA 203 ;Store It in 203
1543 96 RTS ;Return to BASIC
Whenever it is necessary to pass more than one value
to a machine language program, the USR statement looks
like this:
var = USR{addr,expr1,expr2, . . .)
The multiple expressions are passed to the stack as 2-
byte integer values, and their MSB appears on the stack
before their LSB does. What's more, the values are placed
On the stack in reverse order: expri will be buried deeper
in the stack than any other expressions that follow it in the
USR function. Fig. 7-4 illustrates how the stack should be
handled whenever the USR function passes more than
one value to it.
298
TOP OF
STACK
1_
NO. OF VALUES
FIRST VALUE
PASSED
1BYTE
MSB I
LSB|
2 BYTES
TOP OF
STACK
2 BYTES
MSB
LSB
CURRENT
CONTENTS
FINAL VALUE
PASSED
BASIC RETURN
ADDRESS
MSB 1 2 BYTES
LSB I
(A) Stack prior to executing USR.
(C) The necessary condition of
the stack before using an
RTS statement to return to
BASIC.
(B) Stack just after executing the
USR.
TOP OF
STACK
BASIC RETURN
ADDRESS
MSB
LSB
2
BYTES
Fig. 7-4. The system stack when passing multiple variables under
USR commands.
The following version of the USR function passes the
length and address location of a string, M$:
X = USR(1536,LEN(M$),ADR(M$))
Having done that, the number-of-values byte will appear
on the top of the stack, followed by the results of the LEN
function, the results of the ADR function, and the return-
ing address for BASIC. As in the earlier instances, the MSB
for a given value appears on top of its LSB.
299
Passing Values From a Machine Language Routine
The previous discussions treat the USR function in such a
way that the \/ar is a simple dummy variable. It takes on
some meaning, however, when a machine language rou-
tine is supposed to pass a numerical value back to basic.
Consider this portion of a BASIC program that loads and
executes a machine language routine:
100 X=USR{1536)
110 PRINT X
The idea is to initiate some sort of machine language
routine from address 1536. And assuming that the routine
generates a meaningful numerical value, it can be re-
turned to BASIC as assigned to variable X. In order to do
that, however, the machine language routine must save
the value in address locations 212 and 213 (LSB followed by
MSB).
Alternatively, you can return values from machine lan-
guage to BASIC by storing the values to some well-defined
RAM locations; and after returning to BASIC, fetch the
values by means of PEEK statements.
SCREEN DISPLAY LISTS
The ATARI system's ANTIC hardware device is actually a
small microprocessor in its own right; and like a micro-
processor, it can be programmed to perform some special
tasks.
The primary purpose of ANTIC is to control all the fea-
tures of the display, and those features are developed by
the special ANTIC programming, called the display list.
The ANTIC Instruction Set
The ANTIC instruction set includes codes for leaving a
designated number of blank lines on the screen, setting
up 14 different kinds of screen formats, and two kinds of
address jumps.
300
Chapter 4 describes eight basic screen formats that are
directly accessible from BASIC. ANTIC actually allows 14
screens; but of equal importance is the fact that ANTIC
uses different screen-number assignments than BASIC
does. Table 7-1 lists all available screen formats.
Table 7-1 . ANTIC'S Screen Modes
ANTIC
BASIC
Pixels
Bytes
TV Lines
Bits per
Mode
Mode
(horiz.)
per Line
per Pixel
Pixel
2
40
40
8
8
3
none
40
40
10
8 Character
4
none
40
40
8
8 Modes
5
none
40
40
16
8
6
1
20
20
8
8
7
2
20
20
16
8
8
3
40
10
8
2
9
4
80
10
4
1 Bit-Mapped
10
5
80
20
4
2 Graphics
11
6
160
20
2
1 Modes
12
none
160
20
1
1
13
7
160
40
1
2
14
none
160
40
8
2
15
8
320
40
16
1
Notice that BASIC'S Mode-0 screen is called mode 2 as
far as ANTIC is concerned. Also notice that ANTIC offers
five additional screen modes. The columns of data asso-
ciated with each mode indicate the number of pixels per
line (under normal screen width), the number of screen
data bytes per line, the number of tv vertical scan lines per
pixel, and the number of screen data bits per pixel. As
described later, the number of tv vertical scan lines per
pixel is an especially important number when composing
the display list.
Chart 7-1 shows the basic display list instruction set. The
instruction set actually uses most of the decimal values
between and 255, but the ones shown here represent the
starting points.
301
Chart 7-1 . ANTIC Display List Instruction Set
HSCROL
N
Y
N
Y
N
Y N Y
VSCROL
N
N
Y
Y
N
N Y Y
LMS
N
N
N
N
Y
Y Y Y
BLK
1
Blank lines
BLK
2
16
16
16
16
16
16 16 16
BLK
3
32
32
32
32
32
32 32 32
BLK
4
48
48
48
48
48
48 48 48
BLK
5
64
64
64
64
64
64 64 64
BLK
6
96
96
96
96
96
96 96 96
BLK
7
112
112
112
112
112
112 112 112
BLK
8
128
128
128
128
128
128 128 128
JMP
JVB
1
65
1
65
1
65
1
65
1
65
1 1 1
65 65 65
Jumps
CHR
2
2
18
34
50
66
82 98 114
BASIC Mode
CHR
3
3
19
35
51
67
83 99 115
CHR
4
4
20
36
52
68
84 100 116
CHR
5
5
21
37
53
69
85 101 117
CHR
6
6
22
38
54
70
86 102 118
BASIC Mode 1
CHR
7
7
23
39
55
71
87 103 119
BASIC Mode 2
MAP
8
8
24
40
56
72
88 104 120
BASIC Mode 3
MAP
9
9
25
41
57
73
89 105 121
BASIC Mode 4
MAP 10
10
26
42
58
74
90 106 122
BASIC Mode 5
MAP 11
11
27
43
59
75
91 107 123
BASIC Mode 6
MAP 12
12
28
44
60
76
92 108 124
MAP 13
13
29
45
61
77
93 109 125
BASIC Mode 7
MAP 14
14
30
46
62
78
94 110 126
MAP 15
15
31
47
63
79
95 111 127
BASIC Mode 8
NOTE: Add 1 28 to ANTIC Opcodes to obtain the corresponding Instruc-
tion Interrupt codes.
The BLNK instructions indicate the number of succes-
sive blank lines that are to appear on the screen, and the
ANTIC instructions dictate the screen mode to be applied
for the current number of vertical scan lines. Referring to
Table 7-1, for example, ANTIC mode 10 uses 4 scan lines
per pixel; so an ANTIC 10 display-list instruction will apply
that mode to 4 successive tv scan lines. And if you happen
to want 8 such lines in succession, the display list must
show two ANTIC 10 instructions in succession.
The only difference between the two jump instructions
is that JVB waits for the next tv vertical retrace before it is
executed. JMP does not. Both instructions must be fol-
lowed by a 2-byte destination address.
302
JVB is always used at the end of a display list; it usually
jumps the ANTIC programming back to the beginning of
the display list. It is altogether possible to interweave dif-
ferent kinds of screen formats, however, by doing a JVB to
the beginning of a different display-list program.
The simpler JMP instruction is used only when the
display-list addressing crosses a Ik boundary — something
most programmers prefer to avoid in the first place.
Structure of a Display List
As in the case of any sort of microprocessor programming,
display-list programming for the ANTIC chip must follow
some strict rules.
First, every display list must begin by specifying 24 con-
secutive blank lines. This requirement eliminates difficul-
ties that are associated with tv vertical overscan. Using the
fewest possible number of instructions, the 24 lines can be
specified by three BLNK 8 instructions in succession:
112
112
112
The second step in the program is to point to the start-
ing address of the screen RAM to be used for the project.
That is a matter of loading ANTIC's memory-screen coun-
ter with that address; and that is done by invoking the
LMS option.
The LMS option is invoked by summing a value of 64
with the ANTIC mode instruction to be used next. So if
you are setting up ANTIC mode 10, invoke the LMS by
means of instruction code 10 + 64, or 74.
But that isn't all. The LMS instruction must be followed
by a 2-byte version of the starting address of the screen
RAM. If you are planning to set the screen RAM from
address 40960, the LMS instruction must be followed by
(the LSB) and 160 (the MSB).
303
Thus far, the display list programming looks like this:
112 BLNK 8
112 BLNK 8
112 BLNK 8
74 LMS, ANTIC 10
(to address 40960)
160
It specifies the initial 24 blank lines, establishes the begin-
ning of the screen RAM at address 40960, and draws the
first 4 vertical scan lines of an ANTIC mode 10 screen.
In the simplest case, the third step is to continue specify-
ing ANTIC mode instructions until the total number of
vertical scan lines (including blanks) is equal to 192. The
example just cited is using ANTIC mode 10—4 scan lines
per operation, so adding 41 consecutive ANTIC 10 instruc-
tions completes the screen.
NOTE: A display list must account for no more than 192
vertical scan lines— the number of lines required for filling
the screen. It is possible to use fewer lines to shorten the
screen, but using more than 192 lines causes undesirable
video effects.
After accounting for all of the lines, usually 192 of them,
the final step is to apply the JVB instruction. The purpose is
to wait for the next vertical blanking interval, and then
loop the display list back to the beginning. That is a 3-byte
instruction that begins with the JVB op code, 65, followed
by a 2-byte rendition of the RAM starting address of the
display list.
So if you decide to locate your display list at address
32768 (it is generally located just below the screen RAM
area), then the final three instructions look like this:
65 JVB
(to 32768)
144
304
Table 7-2 shows the actual display list for BASIC'S Mode-
3 screen. Notice how it begins with three BLNK 8 instruc-
tions in sequence, followed by an LMS for ANTIC mode 8
that points to the starting address of that screen— 40560.
After that, there is a series of ANTIC 8 down to the point
where the text window is to appear.
Table 7-2. Display List for the Mode-3 Screen
305
The beginning of the ANTIC Mode 7 text window is
marked by an LMS instruction that points to the beginning
of the screen addressing for that part of the display— to
address 40800. The program concludes with three addi-
tional ANTIC 7 lines and a JVB back to the beginning of
the display list at 40526.
That is a good example of a mixed-mode display list.
There are two additional rules that must apply in all
instances:
1. A JMP instruction must be used wherever the
display-list programming must cross a Ik boundary
value.
2. An LMS instruction must be used wherever the
screen addressing crosses a 4k boundary address.
Both situations can be avoided by being very selective
about the choice of starting addresses for the display list
and screen RAM. They most often arise, however, when it
is necessary to conserve RAM and, of course, when using
very long and complex display lists or large screen RAM
areas.
Other display list options include horizontal scrolling
(HSCROL), vertical scrolling (VSCROL) and display inter-
rupts (INT). They are invoked in a fashion similar to LMS—
by summing certain values with the current ANTIC mode
or BLNK code (see Chart 7-2).
Locating the Display List
The display-list programming generally takes up a lot less
RAM space than the screen RAM will. Programmers thus
tend to specify the screen RAM area first, avoiding a 4k
boundary value wherever possible.
The display list, more by convenience and convention
than necessity, is generally located below and as close as
possible to the beginning of the screen RAM. And, where
feasible, the display-list addressing should not cross a Ik
boundary.
306
Chart 7-2. Summary of Display-List Options
For mode instructions— mode=ANTIC+HSCROL+VSCROL+LMS+INT
For blank instructions— blank=BLNK+INT
Where:
mode=op code for a mode line
blank=op code for a blank line
ANTIC=the current ANTIC mode number (Table 7-1 )
BLNK=the current BLNK number (Table 7-1)
HSCROL: 0=no horizontal scrolling
1 6=horizontal scrolling
VSCROL; Ono vertical scrolling
32=vertical scrolling
LMS: 0=LMS not invoked
64=LMS invoked
INT: 0=no interrupt
1 28=interrupt invoked
The starting address of the screen RAM then becomes
part of the display list — inserted by means of an LMS
instruction. The starting address of the display list, itself,
usually appears as part of the JVB instruction at the end of
the display list.
Once the display list is loaded into RAM, it is necessary
to POKE its starting address into SDSTL, addresses 560 and
561; but that can be done properly only if the DMA con-
trol (address 559) is turned off during the POKE intervals.
The routine generally takes this form:
POKE 559,0 (disable DMA)
POKE 560,lsb of list address
POKE 561, msb of list address
POKE 559,34 (enable DMA for standard playfield)
A LOOK AT TOKENIZED BASIC
BASIC is an interpretive language. That is, the computer
reads each instruction in the program just prior to using it.
It follows, then, that programs using shorter statements
can be executed faster and loaded into smaller amounts of
307
RAM. A system that would have to read every character in
every line of a program would be terribly slow-acting and
take up a great deal of RAM space.
BASIC gets around that difficulty by translating every
valid command, statement, function and operator into a
1-byte token. Variable names and constant values are still
carried in the usual ATASCIi forms, but virtually every-
thing else is tokenized. See the list of ATARI BASIC tokens
in Tables 7-3 through 7-5.
Table 7-3. Command Tokens
Code
Command
Code
Command
REM
28
POINT
1
DATA
29
X10
2
INPUT
30
ON
3
COLOR
31
POKE
4
LIST
32
PRINT
5
ENTER
33
RAD
6
LET
34
READ
7
IF
35
RESTORE
8
FOR
36
RETURN
9
NEXT
37
RUN
10
GOTO
38
STOP
11
GOTO
39
POP
12
GOSUB
40
?
13
TRAP
41
GET
14
BYE
42
PUT
15
CONT
43
GRAPHICS
16
COM
44
PLOT
17
CLOSE
45
POSITION
18
CLR
46
DOS
19
DEG
47
DRAWTO
20
DIM
48
SETCOLOR
21
END
49
LOCATE
22
NEW
50
SOUND
23
OPEN
51
LPRINT
24
LOAD
52
CSAVE
25
SAVE
53
CLOAD
26
STATUS
54
implied LET
27
NOTE
55
ERROR - (syntax)
308
Table 7-4. Operator Tokens
Code
Operator
Code
Operator
14
num constant
37
+
15
string constant
38
-
16
not used
39
/
17
not used
40
NOT
18
,
41
OR
19
$
42
AND
20
: (end of statement)
43
(
21
1
44
)
22
end of line
45
= (num assign)
23
GOTO
46
= (str assign)
24
GOSUB
47
<= (string)
25
TO
48
<>
26
STEP
49
> =
27
THEN
50
<
28
#
51
>
29
< = (numeric)
52
=
30
<>
53
+ (unary)
31
> =
54
-
32
<
55
( (as in a string)
33
>
56
( (array)
34
=
57
( (array)
35
58
( (function)
36
«
59
( (dimension)
60
, (as in an array)
Unless directed otherwise, BASIC programs are saved
on tape or disk in this tokenized form. However, Chapter
6 describes conditions where it is more desirable to deal
with a nontokenized version — a version where every
character in every BASIC statement is literally saved as an
ATASCII character.
309
Table 7-5. Function Tokens
Code
Function
61
STR$
62
CHR$
63
USR
64
ASC
65
VAL
66
LEN
67
ADR
68
ATN
69
COS
70
PEEK
71
SIN
72
RND
73
FRE
74
EXP
75
LOG
76
CLOG
77
SQR
78
SGN
79
ABS
80
INT
81
PADDL
82
STICK
83
PTRIG
84
STRIG
310
Chapter 8
The ATARI Memory Map
Fig. 8-1 shows the general memory map for the ATARI
system. It is divided into two main parts: a RAM area
between addresses and 49152, and a ROM area from
49152 through 65535.
The ROM area is common to all systems, regardless of
the amount of RAM that is installed. The minimum RAM
area (8k) is situated between addresses and 8192. The
material in this chapter deals most extensively with those
two portions of the ATARI memory map.
Thus, any working ATARI system has at least 8k of RAM
installed at the lower end of the memory map. A 16k sys-
tem includes that RAM area plus an additional 8k of RAM
between addresses 8192 and 16383. A 32k system would
have RAM available up to address 32767.
A 48k system has RAM available through address 49151.
Notice from the overall memory map that the upper 16k
of RAM in such a system overlaps the left- and right-
cartridge areas. The cartridges are actually ROM devices;
and in a 48k system, the cartridge ROM operations take
full precedence over any RAM that they overlay.
So if you happen to have a 48k system and install a
cartridge in the left-cartridge area, you will still have some
RAM available in the right-cartridge area (between
addresses 32768 and 40959).
Table 8-1 summarizes the RAM area that is generally
available to the user when the BASIC cartridge is installed.
311
65535
57344-
55296-
53248-
49152-
40960-
32768-
8192-
SYSTEM ROM AREA
(8K)
FLOATING-POINT ROM (2K)
HARDWARE I/O ROM (2K)
UNUSED ROM (4K)
LEFT CARTRIDGE RAM AREA
(8K)
MODEL 800 RIGHT CARTRIDGE
RAM AREA (8K)
EXPANSION RAM AREA
(24K)
SYSTEM RAM AREA
(8K)
•$FFFF
•SEGOO
'$D800
.$D0OO
-$C000
■$A00O
$8000
.$2000
$00
Fig. 8-1. OverallmemorymapoftheATARIHomeComputersystem.
Table 8-1 . Range of RAM Addresses Available to the
User as a Function of the Amount of Installed RAM.
It Is Assumed That the Standard ATARI Home
Computer BASIC Cartridge is Installed
RAIM
Size
RAM Address Range
Available
Decimal
Hexadecimal
8k
16k
32k
48k
1536-8191
1536-16383
1536-32767
1 536-40959
$0600-$1FFF
$0600-$3FFF
S0600-$7FFF
$0600-$9FFF
NOTE: If DOS is installed, the lowest-usable RAM address is raised to
10879 ($2A7F). DOS thus requires at least a 16k system.
312
ZERO-PAGE AND STACK RAM
The ATARI system uses a 6502 microprocessor as the cen-
tral processor unit (CPU); and it is the nature of that
device that dictates the application of the RAM area from
address through 255 ($00-$FF). Using conventional 6502
terminology, the first half of that area is called the zero-
page, and it has special significance in terms of machine-
language addressing. (See the 6502 instruction set in Chap-
ter 9.)
The second half of this RAM area is normally dedicated
entirely to 6502 stack operations; and a programmer
should use it only when fully aware of those internal
operations.
ATARI Home Computer engineers have divided the
zero-page RAM, itself, into two equal sections. The lower
section, 0-127, is used for the general operating-system
and the remainder, addresses 128-255, is used for BASIC'S
zero-page operations.
Chart 8-1 outlines the usage of the operating-system
portion of the zero-page area, and Chart 8-2 outlines the
portion used by BASIC.
Chart 8-1 .Operating System Usage
of the Zero-Page RAM: 0-1 27
$00-$01 0-1 LNZBS
Application is unclear.
$02-$03 2-3 CASINI
Successful cassette boot initialization data and addresses.
$04-$05 4-5 RAMLO
RAM test pointer during Initialization.
$06 6 TRAMSZ
Page number of highest available RAM address. Value is passed to
RAMTOP at $6A$ (106) after initialization is done.
$07 7 TSTDAT
RAM-test register; set to 1 when a cartridge is inserted in the right-
hand (B) slot.
313
Chart 8-1— com. Operating System Usage
of the Zero- Page RAM: 0-127
^08 8 WARMST
Warm-start flag; it is set to during cold start.
$09 9
Successful disk-boot flag.
BOOT?
$OA-$OB 10-11 DOSVEC
Diskette vector; points to start of BASIC programs.
$OC-$OD 12-13
Disk-boot initialization vector.
DOSINI
$OE-$OF 14-15 APPMHI
Lowest RAM address available for screen memory.
$10 16
POKEY interrupt mask.
POKMSK
$11 17
BREAK-key flag: = break
$80(120) = no break
BRKKEY
$12-$14 18-20
Real-time clock.
RTCLOK
$15-$16 21-22 BUFADR
Temporary zero-page address pointer for disk buffer.
$17 23
Command table index pointer.
ICCOMT
$1A-$1B 26-27
Disk utility address.
DSKUTL
$1C 28
Printer time-out value.
PTIMOT
$1D 29
Printer buffer index pointer.
PBPNT
$1E 30
Printer-buffer record size.
PBUFSZ
S1F 31 PTEMP
Temporary register for next character to printer.
$20 32 ICHIDZ
Current device handler index number.
314
Chart 8-1— cont. Operating System Usage
of the Zero-Page RAM: 0-1 27
$21 33
Current device drive number.
ICDNOZ
$22 34
Current device command number.
ICCOMZ
$23 35
Last-returned status code.
ICSTAZ
$24-$25
36-37
ICBALZ
ICBAHZ
Command buffer address pointer.
$26-$27 38-39
PUT-byte address pointer.
ICPTLZ
ICPTHZ
S28-$29 40-41 ICBLLZ
ICBLHZ
Buffer length for GET and PUT operations.
S2A-$2B 42-43 ICAX1Z
ICAX2Z
2-byte auxiliary registers; used mainly for I/O control block op-
erations.
$2C-$2F 44-47
Temporary-storage registers.
ICSPRZ
$30 48
Internal status register.
STATUS
$31 49 CHKSUM
Checksum register for detecting frame-transfer errors.
$32-$33 50-51 BUFRLO
BUFFRH
Next-byte address pointer for buffer operations.
$34-$35 52-53
End-of-buffer byte pointer.
BFENLO
BFENHI
$36 54
Command retry counter.
CRETRY
$37 55
Device retry counter.
DRETRY
315
Chart 8-1— com. Operating System Usage
o^the Zero-Page RAM: 0-1 27
$38
Buffer full flag.
56
$39 57
Receive-done flag.
$3A 58
Transmlt-done flag.
$3B 59
Checksum byte-sent flag:
= not sent
$FF (255) = sent
$3C 60
No-checksum-coming flag:
= checksum is coming
NOT = no checksum
S3D 61
Cassette buffer Index pointer.
$3E 62
Type flag for inter-record gap.
$3F 63
Cassette end-of-file flag:
= not EOF
$FE (255) = EOF
$40 64
Cassette read/write BEEP count:
1 = play
2 = record
$41 65
Audio sound flag: = no noise
$42 66
Critical-code flag.
$43-$44 67-68
Buffer address pointer.
$45-S46 69-70
Drive address pointer.
BUFRFL
RECVDN
XMTDON
CHKSNT
NOCKSM
BPTR
FTYPE
FEOF
FREQ
SOUNDR
CRITIC
ZBUFP
ZDRVA
316
Chart 8-1— cont. Operating System Usage
of the Zero- Page RAM: 0-127
$47-$48 71-72 ZSBA
Sector buffer address pointer.
$49 73 ERRNO
Error number for disk operations.
$4A 74 CKEY
Cassette-boot request flag.
$4B 75 CASSBT
Boot flag:
= disk boot
1 = cassette boot
$4C 76 DSTAT
Display status.
$4D 77 ATRACT
ATTRACT mode timer register/flag. Increments from Oto $7F(127)at
4 second intervals after 9 minutes of no key activity. Set to $FE (254)
at the end of that timing interval.
$4E 78 DRKMSK
Dark-color mask used during ATTRACT mode to reduce screen lumi-
nance. Has a value of $FE (254) when ATTRACT is inactive, and $F6
(246) when active.
$4F 79 COLRSH
Color-shift mask register used in ATTRACT mode. Has value of
when ATTRACT is inactive.
$50 80 TMPCHR
Temporary register screen data during transfer.
$51 81 H0LD1
Temporary register for number of entries In a display list.
$52 82 LMARGN
Screen address of the left text margin.
Range: $0-$27 (0-39)
$53 83 RMARGN
Screen address of the right text margin.
Range: $0-27 (0-39)
317
Chart 8-1— cont. Operating System Usage
of the Zero-Page RAM: 0-127
554 84 ROWCRS
Row address of the current cursor position.
Range: $00-$BF (0-191)
$55-$56 85-86 COLORS
Column address of current cursor position.
Range: $00-$13F (0-319)
*57 87 DINDEX
Index value of current screen mode.
$58-$59 88-89 SAVMCS
Address of upper-left corner of display.
*5A 90 OLDROW
Row address of the previous graphics cursor position.
$5B-S5C 91-92 OLDCOL
Column address of the previous graphics cursor position.
«5D 93 OLDCHR
Holds screen character while it is "hidden" by the text cursor.
$5E-$5F 94-95 OLDADR
Screen memory address of current text cursor location.
S60 96 NEWROW
Row destination for next LINE/DRAW step.
$61 -$62 97-98 NEWCOL
Column destination for next LINE/DRAW step.
$63 99 LOGCOL
Logical-line column number for the current cursor position.
$64-$65 100-101 ADRESS
General-purpose 2-byte register.
$66-$67 102-103 MLTTMP
OPNTMP
Multipurpose 2-byte register; used with OPEN command and as
address pointer.
$68-$69 104-105 SAVADR
FRNADR
General-purpose 2-byte register.
318
Chart 8-1— cont. Operating System Usage
of the Zero-Page RAM: 0-1 27
$6A 106 RAMTOP
Page number of highest available RAM address. Used by display
handler.
m 107 BUFCNT
Current logical line-size counter.
$6C-$6D 108-109 BUFSTR
Temporary 2-byte register used with display routines.
$6E 110
Temporary register for bit masks.
BITMSK
$6F 111 SHFAMT
Amount of pixel shift required to right-justify the data.
$70-$71 112-113 ROWAC
Accumulator for row-counting during plotting operations.
$72-$73 114-115 COLAC
Accumulator for column-counting during plotting operations.
$74-$75 116-117 ENDPT
End point designation for a line being plotted to the screen.
$76 118 DELTAR
Change in screen row position (vertical component) of a slope drawing.
$77-$78 119-120 DELTAC
Change in screen column position (horizontal component) of a slope
drawing.
$79 121
Drawing row direction:
$01 (1) = down
$FF(255) = up
ROWING
$7A 122
Drawing column direction:
$01 (1) = right
$FF (255) = left
COLINC
$78 123
Split-screen cursor flag:
= normal
$FF (255$) = swapped
SWPFLG
319
Chart 8-1— cont. Operating System Usage
of the Zero-Page RAM: 0-1 27
*7C 124 HOLDCH
Current character code for subsequent SHIFT or CONTROL logic.
«7D 125 INSDAT
Cursor-related temporary storage.
$7E-$7F 126-127 COUNTR
Number of steps involved in drawing a line.
Chart 8-2. BASIC Usage
of the Zero-Page RAM: 128-255
$80-$81 128-129 LOMEM
Starting address of resident BASIC programming features.
$82- $83 130-131 VNTP
Starting address of BASIC variable table.
$84-$85 132-133 VNTD
Ending address of BASIC variable table.
$86-$87 134-135 WTP
Variable table pointer.
$88- $89 136-137 STMTAB
Starting address of BASIC statement table.
$8A-$8B 138-139 STMCUR
BASIC statement pointer.
$8C-$8D 140-141 STARP
Address of the end of the string and array table.
$8E-$8F 142-143 RUNSTK
BASIC stack for GOSUB, FOR-NEXT, etc.
$90-$91 144-145 MEMTOP
Top of BASIC programming area.
$92-$D3 146-211
Reserved for general BASIC operations.
320
Chart 8-2— cont. BASIC Usage
of the Zero-Page RAM: 1 28-255
$D4-$D9 212-217
Floating-point register 0.
FRO
$DA-$DF 218-223
Spare floating-point registers.
FRE
$E0-$E5 224-229
Floating-point register 1 .
FR1
$E6-$EB 230-235
Floating-point register 2.
FR2
$EC 236
Not used.
FRX
$ED 237
Exponent value.
EEXP
SEE 238
Sign of floating-print value.
NSIGN
$EF 239
Sign of floating-point exponent.
ESIGN
$F0 240 FCHRFLG
First-character flag for floating-point operation.
$F1 241
Number of digits to right of decimal
DIGRT
point.
SF2 242
Character index for input buffer.
CIX
$F3-$F4 243-244 INBUFF
Input buffer pointer for ATASCII text.
$F5-$F6 245-246
Temporary registers.
ZTEMP1
$F7-$F8 247-248
Temporary registers.
ZTEMP4
321
Chart 8-2— cont. BASIC Usage
of the Zero-Page RAM: 128-255
$F9-$FA 249-250 ZTEMP3
Temporary registers.
5FB 251 RADFLG
DEGFLG
Angle flag:
= radians
6 = degrees
$FC-$FD 252-253 FLPTR
Floating-point number pointer.
$FE-$FF 254-255 FPTR2
Floating-point second number pointer.
OPERATING SYSTEM AND BASIC RAM
The ATARI Home Computer's main operating system uses
a significant portion of the system RAM area; and when
the BASIC cartridge is installed, it, too, uses some system
RAM. Exploring both of these areas can turn up a wealth
of potentially useful information.
Operating System RAM: 512-1151
Chart 8-3 outlines the operating system RAM area. Most
of the comments accompanying the addresses and labels
are sufficient to define their function for anyone who is
familiar with the fundamental internal workings of a com-
puter and is willing to experiment with some PEEKs and
POKES.
322
Chart 8-3.0perating-Sy8tem RAM: 512-1151
$020O-$02O1 512-513
Display-list interrupt vector.
VDSLST
$0202-$0203 514-515
I/O proceed vector.
VPRCED
$0204-$0205 516-517
I/O interrupt vector.
VINTER
$0206-$0207 518-519
BREAK vector.
VBREAK
$0208-$0209 520-521
Keyboard interrupt vector.
VKEYBD
$020A-$020B 522-523
Serial input ready vector.
VSERIN
$02CX;-$020D 524-525
Serial output ready vector.
VSEROR
$020E-$020F 526-527
Serial transfer complete vector.
VSEROC
$0210-$0215 528-533
POKEY timer vectors.
VITMR1
VITMR2
VITMR4
$0216-$0217 534-535
Interrupt-request vector.
VIMIRO
$0218-$0219 536-537 CDTMV1
System timer-1 value; decrements with each VBLANK.
$021A-$021B 538-539
System timer-2 value.
CDTMV2
$021C-$0221 540-545
System timers 3, 4, and 5.
CDTMV3
CDTMV4
CDTMV5
$0222-$0223 546-547
VBLANK interrupt vector.
VVBLKI
$0224-$0225 548-549
Return from VBLANK interrupt
VVBLKD
vector.
323
Chart 8-3— cont. Operating-System RAM: 512-1151
$0226-$0227 550-551
System timer-1 jump address.
CDTMA1
$0228-$0229 552-553
System timer-2 jump address.
CDTMA2
$022A 554
System timer-3 time-out flag.
CDTMF3
$022B 555
Key-repeat timer.
SRTIMR
$022C 556
System timer-4 time-out flag.
CDTMF4
$022D 557
Temporary integer register.
INTEMP
S022E 558
System timer-5 time-out flag.
CDTMF5
$022F 559
DMA enable/control.
SDMCTL
$0230-$0231 560-561
Starting address of display list.
SDLSTL
SDLSTH
S0232 562 SSKCTL
Copy of serial port control register $D20F (53775).
$0233
Not used.
563
$0234 564
Light pen horizontal position.
LPENH
$0235 565
Light pen vertical position.
LPENV
$0236-$0237 566-567
Spare; or possible BREAK key vector.
$0238-$0239
Not used.
568-569
$023A 570
Current I/O device number.
CDEVIC
324
Chart 8-3— cont. Operating-System RAM: 512-1 151
$023B 571
Bus command code.
CCOMND
$023C-$023D 572-573
Auxiliary registers.
CAUX1
CAUX2
$023E 574
Temporary I/O data register.
TEMP
$023F 575
I/O error flag.
ERRFLG
$0240 576
Disk flags.
DFLAGS
$0241 577
Disk-boot sector counter.
DBSECT
$0242-$0243 578-579
Address of disk-boot loader.
BOOTAD
$0244 580
Cold-start complete flag:
= end of start
1 = start not done
COLDST
$0246 582
Disk timeout register.
DSKTIM
$0247-$026E 583-622 LINBUF
40-byte physical line buffer; used when moving screen
data.
$026F 623
Priority control for display handler.
GPRIOR
$0270 624
Paddle position.
PADDLO
$0271 625
Paddle 1 position.
PADDL1
$0272 626
Paddle 2 position.
PADDL2
$0273 627
Paddle 3 position.
PADDL3
325
Chart 8-3— cont. Operating-System RAM: 512-1 151
$0274 628
Paddle 4 position.
$0275 629
Paddle 5 position.
$0276 630
Paddle 6 position.
$0277 631
Paddle 7 position.
$0278 632
Joystick position.
$0279 633
Joystick 1 position.
$027A 634
Joystick 2 position.
$0278 635
Joystick 3 position.
S027C 636
Paddle trigger sense:
= pressed
1 = not pressed
$027D 637
Paddle 1 trigger sense:
= pressed
1 = not pressed
$027E 638
Paddle 2 trigger sense:
= pressed
1 = not pressed
$027F 639
Paddle 3 trigger sense:
= pressed
1 = not pressed
$0280 640
Paddle 4 trigger sense:
= pressed
1 = not pressed
PADDL4
PADDL5
PADDL6
PADDL7
STICKO
STICK 1
STICK2
STICK3
PTRIGO
PTRIG1
PTRIG2
PTRIG3
PTRIG4
326
Chart 8-3— cont. Operating-System RAM: 512-1 151
$0281 641
Paddle 5 trigger sense;
= pressed
1 = not pressed
PTRIG5
$0282 642
Paddle 6 trigger sense:
= pressed
1 = not pressed
PTRIG6
$0283 643
Paddle 7 trigger sense:
= pressed
1 = not pressed
PTRIG7
$0284 644
Joystick trigger sense:
= pressed
1 = not pressed
STRIGO
$0285 645
Joystick 1 trigger sense:
= pressed
1 = not pressed
STRIG1
$0286 646
Joystick 2 trigger sense:
= pressed
1 = not pressed
STRIG2
$0287 647
Joystick 3 trigger sense:
= pressed
1 = not pressed
STRIG3
$0289 649
Cassette read/write flag:
= read
$80(128) = write
WMODE
$028A 650 BUM
Number of bytes in cassette record buffer.
$028B-$028F 651-655
Unused.
$0290 656
Row address for the current
TXTROW
split-screen cursor position.
327
Chart 8-3— cont. Operating-System RAM: 512-1 151
$0291 $0292 657-658 TXTCOL
Column address for the current split-screen cursor position.
$0293 659 TINDEX
Screen mode number for split-screen operations.
S0294-$0295 660-661 TXTMSC
Display address of upper-left corner of text window during split-screen
operations.
$0296-$029B 662-667 TXTOLD
Split-screen, previous cursor information: row, column, character and
display address.
S029C 668
Temporary-storage register.
$029D 669 H0LD3
Temporary-storage register.
$029E 670 SUBTMP
Temporary-storage register.
S029F 671 H0LD2
Temporary-storage register.
$02A0 672 DMASK
Data mask for locating graphics pixels; affected by current screen
mode.
$02A1 673 TMPLBT
Temporary register for bit masks.
S02A2 674 ESCFLG
Escape-key flag; set to $80 (128) by ESC keystroke; returned by at
subsequent keystroke.
$02A3-$02B1 675-689 TABMAP
Cursor tab settings for the 1 5 logical lines on the screen.
$02B2-$02B5 690-693 LOGMAP
Beginning screen-line number for each of the 15 logical lines.
$02B6 694 INVFLG
Inverse-video flag:
= normal video
$80(128) = inverse video
328
Chart 8-3— cont. Operating-System RAM: 512-1 151
$02B7 695 FILFLG
FILL/DRAW command flag:
= DRAW
$FF (255) = FILL
$02B8-$02BA
Temporary row a
696-698 TMPROW
TMPCOL
nd column location registers.
$02BB
Number of lines
operation (minus
699 SCRFLG
deleted from the top of the screen after
1).
a scrolling
$02BC 700 H0LD4
Temporary register for ATACHR during a FILL operation.
$02BE 702 SHFLOK
Shift/control lock mode:
$00 (0) = normal mode
$40 (64) = caps lock
$80(128) = controllock
$02BF 703 BOTSCR
Number of lines available for text. Has $1 8 (24) for GR.O and $04 (4) for
split-screen modes.
$02C0
Color for player
(53266).
704 PCOLRO
and missile 0. Also color for duplicate
in $0012
$02C1
Color for player
(53267).
705 PC0LR1
and missile 1. Also color for duplicate
in $0013
$02C2
Color for player
(53268).
706 PC0LR2
and missile 2. Also color for duplicate
in $0014
$02C3
Color for player
(53269).
707 PC0LR3
and missile 3. Also color for duplicate
in $0015
$02C4 708 COLRO
Color of playfield 0. Also used in $D016 (53270).
$02C5
Color of playfield
709 C0LR1
1 . Also used in $D01 7 (53271 ).
329
Chart 8-3— cont. Operating-System RAM: 512-1151
$02C6 710 C0LR2
Color of playfield 2. Also used in $D018 (53272).
S02C7 711 C0LR3
Color of playfield 3. Also used in $D01 9 (53273).
$02C8 712 C0LR4
Color of playfield 4. Also used in $D01 A (53274).
$02E4 740 RAMSIZ
Page number of highest available RAM address.
$02E5-S02E6 741 -742 MEMTOP
Highest RAM address available to user.
$02E7-$02E8 743-744 MEMLO
Lowest RAM address available to user.
S02EA-$02ED 746-749 DVSTAT
Device status registers.
$02EE-$02EF 750-751 CHBAUDL
CHBAUDH
Cassette baud rate (600 baud); uses $05CC (14846).
$02F0 752 CRSINH
Cursor inhibit flag:
= cursor ON
1 = cursor OFF
$02F1 753 KEYDEL
Keyboard debounce timer.
$02F2 754 CHI
Previous keyboard character code.
$02F3 755 CHACT
Character-mode/control register.
$02F4 756 CHBAS
Character address base.
$02FA 762 CHAR
Code for the most recent character at input or to output.
$02FB 763 ATACHR
Character code for the last-read or last-written ASCII character or plot
point.
330
Chart 8-3— cont. Operating-System RAM: 51 2-11 51
$02FC 764 CH
Character code for the most recently accepted keystroke; set to $FF
(256) when keyboard handler accepts the data.
$02FD 765 FILDAT
Fill color data; used with the FILL command.
$02FE 766 DSPFLG
Display flag for ASCII control characters:
= normal control
NOT = character displayed
$02FF 767
Start/stop flag for screen output:
= don't stop
$FF (255) = stop
SSFLAG
$0300 768
Serial device ID number.
DDEVIC
$0301 769
Device unit number.
DUNIT
$0302 770
Device command.
DCOMND
$0303 771
Device status code.
DSTATS
$0304-$0305 772-773
Device buffer address.
DBUFLO
DBUFHI
$0306 774
Device time-out value.
DTIMLO
$0308-$0309 776-777
Device-transfer byte counter.
DBYTLO
DBYTHI
$030A-$030B 778-779
Auxiliary device-transfer registers.
DAUX1
DAUX2
$030C-$030D 780-781
Starting baud-rate timer reference
TIMER1
value.
$030E 782 ADDCOR
Addition correction flag for baud-rate timer values.
331
Chart 8-3— cont. Operating-System RAM: 512-1151
$030F 783 CASFLG
Cassette flag:
= standard serial I/O
NOT = cassette I/O
$0310-$0311 784-785 TIMER2
Final baud-rate timer reference value.
$0312-$0313 786-787 TEMPI
2-byte temporary register for baud-rate timer operations.
$0315 789 TEMP3
1-byte temporary register; probably used during baud-rate timer
operations.
$0316 790 SAVIO
Serial input data detect register.
«0317 791 TIMFLG
Cassette baud-rate timeout (error) flag-
1 = Ok
= error
$0318 792 STACKP
Operating-system version of the 6502 stack pointer.
$0319 793 TSTAT
Next status byte upon return from a WAIT routine.
$031A-$033F 794-831 HATABS
Handler device table (38 bytes)— device codes and handler addresses.
$0340 832 ICHID (0)
Device handler ID for control block 0.
$0341 833 ICDNO [0]
Device number for control block 0.
$0342 834 ICCOM [0]
Current execution command for control block 0.
$0343 835 ICSTA [0]
Most recent status returned by device for control block 0.
$0344-$0345 836-837 ICBAL.H [0]
Buffer address for data transfer under control block 0.
332
Chart 8-3— cont. Operating-System RAM: 51 2-11 51
$0346-$0347 838-839 ICPTL,H [0]
Address of PUT-a-byte routine for control block 0.
$0348-$0349 840-841 ICBLL.H [0]
Current length of buffer being serviced by control block 0.
$034A-$034B 842-843 ICAX1,2[01
Auxiliary registers for control block 0.
$034C-$034F 844-847 ISCPR [0]
Spare registers for use of handler serviced by control block 0.
$0350 848 ICHID[1]
Device handler ID for control block 1 .
$0351 849 ICDN0[1]
Device number for control block 1 .
$0352 850 ICC0M[1]
Current execution command for control block 1 .
$0353 851 ICSTA[1]
Most recent status returned by device for control block 1 .
$0354-$0355 852-853 ICBAL,H[1]
Buffer address for data transfer under control block 1 .
$0356-S0357 854-855 ICPTL.H [1 ]
Address of PUT-a-byte routine for control block 1 .
$0358-$0359 856-857 ICBLL.H [1]
Current length of buffer being serviced by control block 1 .
$035A-$035B 858-859 ICAX1,2[1]
Auxiliary registers for control block 1 .
$035C-$035F 860-863 ISCPR [1]
Spare registers for use of handler serviced by control block 1 ,
$0360 864 ICHID [2]
Device handler ID for control block 2.
$0361 865 ICDNO [2]
Device number for control block 2.
$0362 866 ICCOM [2]
Current execution command for control block 2.
333
Chart 8-3— cont. Operating-System RAM: 512-1151
$0363 867 ICSTA[2]
Most recent status returned by device for control block 2.
$0364-$0365 868-869 ICBAL.H [2]
Buffer address for data transfer under control block 2.
$0366-$0367 870-871 ICPTL,H [2]
Address of PUT-a-byte routine for control block 2.
$0368-S0369 872-873 ICBLL,H [2]
Current length of buffer being serviced by control block 2.
$036A-$036B 874-875 ICAX1,2[2]
Auxiliary registers for control block 2.
$036C-$036F 876-879 ISCPR [2]
Spare registers for use of handler serviced by control block 2.
$0370 880 ICHID [3]
Device handler ID for control block 3.
$0371 881 ICDNO [3]
Device number for control block 3.
$0372 882 ICCOM [3]
Current execution command for control block 3.
$0373 883 ICSTA [3]
Most recent status returned by device for control block 3.
$0374-$0375 884-885 ICBAL,H [3]
Buffer address for data transfer under control block 3.
$0376- $0377 886-887 ICPTL.H [3]
Address of PUT-a-byte routine for control block 3.
$0378-$0379 888-889 ICBLL.H [3]
Current length of buffer being serviced by control block 3.
$037A-$037B 890-891 ICAX1,2[3]
Auxiliary registers for control block 3.
$037C-$037F 892-895 ISCPR [3]
Spare registers for use of handler serviced by control block 3.
$0380 896 ICHID [4]
Device handler ID for control block 4.
334
Chart 8-3— cont. Operating-System RAM: 512-1151
$0381 897 ICDNO [4]
Device number for control block 4.
$0382 898 JCCOM [4]
Current execution command for control block 4.
$0383 899 ICSTA [4]
Most recent status returned by device for control block 4.
$0384-$0385 900-901 ICBAL.H [4]
Buffer address for data transfer under control block 4.
$0386-$0387 902-903 ICPTL.H [4]
Address of PUT-a-byte routine for control block 4.
$0388-$0389 904-905 ICBLL.H [4]
Current length of buffer being serviced by control block 4.
$038A-S038B 906-907 ICAX1,2[4]
Auxiliary registers for control block 4.
$038C-$038F 908-911 ISCPR [4]
Spare registers for use of handler serviced by control block 4.
$0390 912 ICHID[5]
Device handler ID for control block 5.
$0391 913 ICDNO [5]
Device number for control block 5.
$0392 914 ICC0M[5]
Current execution command for control block 5.
$0393 915 ICSTA [5]
Most recent status returned by device for control block 5.
$0394-$0395 916-917 ICBAL.H [5]
Buffer address for data transfer under control block 5.
$0396-$0397 918-919 ICPTL.H [5]
Address of PUT-a-byte routine for control block 5.
$0398-$0399 920-921 ICBLL.H [5]
Current length of buffer being serviced by control block 5.
$039A-$039B 922-923 ICAX1.2[5]
Auxiliary registers for control block 5.
335
Chart 8-3— cont. Operating-System RAM: 512-1151
$039C-S039F 924-927 ISCPR [5]
Spare registers for use of handler serviced by control block 5.
$03A0 928 ICHID [6]
Device handler ID for control block 6.
$03A1 929 ICDNO [6]
Device nunnber for control block 6.
$03A2 930 ICCOM [6]
Current execution command for control block 6.
$03A3 931 ICSTA [6]
Most recent status returned by device for control block 6.
$03A4-$03A5 932-933 ICBAL.H [6]
Buffer address for data transfer under control block 6.
$03A6-$03A7 934-935 ICPTL.H [6]
Address of PUT-a-byte routine for control block 6.
$03A8-$03A9 936-937 ICBLL.H [6]
Current length of buffer being serviced by control block 6.
S03AA-S03AB 938-939 ICAX1,2[6]
Auxiliary registers for control block 6.
$03AC-$03AF 940-943 ISCPR [6]
Spare registers for use of handler serviced by control block 6.
$03B0 944 ICHID [7]
Device handler ID for control block 7.
«03B1 945 ICDNO [7]
Device number for control block 7.
$03B2 946 ICCOM [7]
Current execution command for control block 7.
$03B3 947 ICSTA [7]
Most recent status returned by device for control block 7.
$03B4-$03B5 948-949 ICBAL.H [7]
Buffer address for data transfer under control block 7.
$03B6-$03B7 950-951 ICPTL.H [7]
Address of PUT-a-byte routine for control block 7.
336
Chart 8-3— cont. Operating-System RAM: 512-1 151
$03B8-$03B9 952-953 ICBLL.H |71
Current length of buffer being serviced by control block 7.
$03BA-$03BB 954-955 ICAX1,2[71
Auxiliary registers for control block 7.
$03BC-$03BF 956-959 ISCPR [7]
Spare registers for use of handler serviced by control block 7.
$03C0-$03E7 960-999 PRNBUF
40-byte printer buffer.
$03FD-$047F 1021-1151 CASBUF
1 3 1 -byte cassette buffer.
BASIC System RAM: 1 1 52-1 535
BASIC uses some specified sections of lower RAM for its
purposes. Chart 8-4 outlines those special addresses and
functions for you.
Chart 8-4. BASIC Usage of System RAM: 1 152-1791
$0480-$-057D 1152-1405
BASIC syntax stack; 254 bytes.
$057E-$05FF 1406-1535
INPUT buffer; 1 30 bytes.
$0600-$06FF 1536-1791
User RAM space that is protected from everything but an
INPUT buffer overflow.
Notice the 256-byte RAM area immediately above BAS-
IC'S input line buffer. Generally speaking, this area
(addresses 1536 through 1791) is protected from the oper-
ating system, BASIC and, indeed, DOS as well. It is thus a
fine place to locate machine-coded programs. The only
thing that can go wrong is loading a response to an INPUT
statement that is more than 130 bytes long. Whenever that
happens, the INPUT buffer area extends into this other-
wise "protected" RAM space. Just avoid INPUTting such
large amounts of information at one time.
337
DOS RAM USAGE: 1792-10879
If DOS is not active in the ATARI system, BASIC program-
ming information will normally begin at address 1792.
Booting DOS, however, fills at least 9088 bytes of system
RAM with DOS and file-management programming. As
indicated in Chart 8-5, that programming begins at address
1792 and extends to 10879, or to the current LOMEM set-
ting. That being the case, BASIC programming picks up
from the end of the DOS area.
Chart 8-5. DOS Usage of System RAM: 1792-10879.
or LOMEN
S0700-$12FF 1792-4863
File-management RAM area; 3072 bytes.
$1300-S267F 4864-9855
DOS operating system RAM area; 4992 bytes.
S2680-$2A7F 9856-10879
DOS I/O buffers; 1 024 bytes.
BASIC ROM AREA: 40960-49151
The ATARI BASIC cartridge overlays any RAM that might
be present in the area that it uses. Chart 8-6 offers a map of
that section of the memory map.
Chart 8-6. BASIC ROM AREA: 40960-49151
$A000-$A04C 40960-41036
BASIC cold start routine.
$A04D-$A05F 41037-41055
BASIC warm start routine.
338
Chart 8-6— cont. BASIC ROM Area: 40960-49151
$A060- $A46 1 41 056-4208 1
Syntax checking routine.
$A462-$A4AE 42082-42158
Search routines.
$A4AF- $A60C 42 1 59-42508
Statement name table, with statement token list beginning at
$A4B1 (42161).
$AC0D-$A87E 42509-43134
Operator symbol table, with the operator token list
beginning at $A7E3 (42979).
$A87F-SA95E 43135-43358
Memory manager routines.
$A95F-$A9FF 43359-43519
CONT statement routine.
$AA00-$AA6F 43520-43631
Statement table.
$AA70-$AADF 43632-43743
Operator table.
$AAE0-$AC3E 43744-44094
Routines for executing BASIC expressions.
$AC3F-$AC83 44095-44163
Operator precedence routine.
$AC84-$AFC9 441 64-45001
Operator-execution routines.
SAFCA- SB 1 08 45002-45320
Function-execution routines.
$B109-$B817 45321-47127
Statement-execution routines.
$B818-$B915 47128-47381
Subroutines for CONT statement.
339
Chart 8-6-cont. BASIC ROM Area: 40960-49151
SB916-$B9B6 47382-47542
Error-handling routines.
$B9B7-$BA74 47543-47732
Graphics-handling routines.
$BA75-$BDA4 47733-48548
l/0-handling routines.
$BDA5-$BFF9 48549-49145
Trigonometric function routines.
SBFFA-SBFFB 49146-49147
Left cartridge start address.
SBFFC 49148
Left-cartridge installed byte:
= cartridge installed
nonzero = cartridge not installed
$BFFD-49149
Purpose is unclear.
SBFFE-SBFFF 49150-49151
Cartridge initialization address; jump point after executing
SYSTEM reset under BASIC.
HARDWARE I/O ROM AREA: 53248-55295
Chart 8-7 gives an overview of the hardware I/O ROM
area. This is regarded as ROM only in a casual sense. Some
addresses are devoted to RAM-like read/write opera-
tions; the practical difficulty, from a programmer's point
of view, is that such areas are available for write operations
only during the screen's vertical retrace interval.
Chart 8-7. Hardware I/O ROM Area: 53248-55295
$DOOO-$DOFF
$D100-$D1FF
$D200-$D2FF
$D30O-$D3FF
$D400-$D5FF
SD600-$D7FF
53248-53503
53504-53759
53760-54015
54016-54271
54272-54783
54784-55295
CTIA (or GTIA)
Unused
POKEY
PIA
ANTIC
Unused
340
The CTIA (or GTIA) Device
CTIA, or GTIA, is a piece of system hardware — a proprie-
tary integrated circuit, in fact — that is accessed from
addresses 53248-53503 (see Chart 8-8). The chip is largely
responsible for processing the ATARI'S video information.
Chart 8-8. CTIA (or GTIA)
I/O Map Detail: 53248-53503
SDCXX) 53248 HPOSPO/MOPF
Player horizontal position/missile playfield collision.
SDOOI 53249 HP0SP1/M1PF
Player 1 horizontal position/missile 1 playfield collision.
$D002 53250 HPOSP2/M2PF
Player 2 horizontal position/missile 2 playfield collision.
$D003 53251 HPOSP3/M3PF
Player 3 horizontal position/missile 3 playfield collision.
$D004 53252 HPOSMO/POPF
Missile horizontal position/player playfield collision.
$D005 53253 HP0SM1/P1PF
Missile 1 horizontal position/player 1 playfield collision.
$0006 53254 HPOSM2/P2PF
Missile 2 horizontal position/player 2 playfield collision.
$0007 53255 HPOSM3/P3PF
Missile 3 horizontal position/player 3 playfield collision.
$D008 53256 SIZEPO/MOPL
Size of player 0/missile player collision.
$0009 53257 SIZEP1/M1PL
Size of player 1 /missile 1 player collision.
$D00A 53258 SIZEP2/M2PL
Size of player 2/missile 2 player collision.
$DOOB 53259 SIZEP3/M3PL
Size of player 3/missile 3 player collision.
$DOOC 53260 SIZEM/POPL
Size of all missiles/player player collision.
341
Chart 8-8— com. CTIA (or GTIA)
I/O Map Detail: 53248-53503
SDOOD 53261 GRAFP0/P1PL
Shape of player 0/player 1 player collision.
SDOOE 53262 GRAFP1/P2PL
Shape of player 1 /player 2 player collision.
$DOOF 53263 GRAFP2/P3PL
Shape of player 2/player 3 player collision.
SDOIO 53264 GRPFP3/TRIG0
Shape of player 3/joystick trigger.
«D011 53265 GRAFM/TRIG1
Shape of all missiles/joystick 1 trigger.
$D012 53266 COLOPM0/TRIG2
Color of player and missile 0/joystlck 2 trigger.
$D013 53267 C0L0PM1/TRIG3
Color of player and missile 1 /joystick 3 trigger.
$D014 53268 C0L0PM2/PAL
Color of player and missile 2/European TV sync. flag.
$D015 53269 C0L0PM3
Color of player and missile 3.
$D016 53270 COLPFO
Color of playfield 0.
$D017 53271 C0LPF1
Color of playfield 1 .
$D018 53272 C0LPF2
Color of playfield 2.
$D019 53273 C0LPF3
Color of playfield 3.
SDOIA 53274 COLBK
Color of background.
SDOIB 53275 PRIOR
Figure priority-select; determines whether a figure is to be
located behind or in front of another.
342
Chart 8-8— cont. CTIA (or GTIA)
I/O Map Detail: 53248-53503
$D01 C 53276 VDLAY
Vertical delay; used for moving players or missiles In their
1-llne or 2-llne resolution formats.
SDOID 53277 GRACTL
Turns trigger, missile and player elements on and off.
SDOIE 53278 HITCLR
Flag register for clearing collision events.
SDOIF 53279 CONSOL
Console-button register.
$D020-$D0FF 53280-53503
Duplicate of addresses $D000-$D01 F (53248-53279).
The POKEY Device
Like CTIA, POKEY is a piece of system hardware. It handles
several different kinds of digital tasks, including generat-
ing the audio tones, random noise and numbers, strobing
the keyboard, polling the game ports, and generating tim-
ing pulses.
Chart 8-9 summarizes some of the important addresses
for the POKEY chip.
Chart 8-9. POKEY Map Detail: 53760-54015
$D200 53760 AUDF1 /POTO
Audio voice 1 frequency/paddle setting.
$D201 53761 AUDC1/P0T1
Audio voice 1 volume and distortion/paddle 1 setting.
$D202 53762 AUDF2/POT2
Audio voice 2 frequency/paddle 2 setting.
$D203 53763 AUDC2/POT3
Audio voice 2 volume and distortion/paddle 3 setting.
343
Chart 8-9-cont. POKEY Map Detail: 53760-54015
$D204 53764 AUDF3/P0T4
Audio voice 3 frequency/paddle 2 setting.
$D205 53765 AUDC3/POT5
Audio voice 3 volume and distortion/paddle 5 setting.
$D206 53766 AUDF4/P0T6
Audio voice 4 frequency/paddle 6 setting.
$D207 53767 AUDC4/P0T7
Audio voice 4 volume and distortion/paddle 7 setting.
$D208 53768 AUDCTL/ALLPOT
Audio voice master control/all paddles.
$D209 53769 STIMER/KBCODE
Start POKEY timers/keyboard latch.
$D20A 53770 RANDOM
Random-number counter/register.
$D20B 53771 POTGO
Read paddles flag.
$D20C 53772
Not used.
$D20D 53773 SEROUT/SERIN
Serial I/O register.
$D20E 53774 IRQEN/IRQST
Interrupt request enable and interrupt status request
register.
$D20F 53775 SKCTL/SKSTAT
Serial control and status register; includes keyboard
debounce, keyboard scanning, and serial port mode control.
$D210-$D2FF 53776-54015
Duplicate of SD200-$D20F (53760-53775)
344
The PIA Device
The Peripheral Interface Adaptor (PIA) hardware system is
accessible from addresses 54016 through 54271. Chart 8-10
outlines the functions performed at some of the critical
address locations.
Chart 8-10. PIA Map Detail: 54016-54271
$D300 5401 6
Register for controller jacks 1 and 2.
PORTA
$D301 5401 7
Register for controller jacks 3 and 4.
PORTB
$D302 5401 8
Port A control register.
PACTL
$0303 54019
Port B control register.
PBCTL
$D304-SD3FF 54020-54271
Duplicates of $D300-$D303 (5401 6-5401 9)
The ANTIC Device
ANTIC is a hardware device that is largely responsible for
the ATARI system's unique graphics capabilities. Chart 8-
11 lists the important addresses for that chip.
Chart 8-1 1 . ANTIC Map Detail: 54272-54303
$0400 54272
Direct-memory-access control (DMA
DMACTL
$D401 54273
Character mode control.
CHACTL
$D402-$D403 54274-54275
Display list pointer.
DLISTL
DLISTH
$0404 54276
Horizontal-scroll enable.
HSCROL
345
Chart 8-1 1 -com. ANTIC Map Detail: 54272-54303
$D405 54277 VSCROL
Vertical-scroll enable.
$0406 64278
Unused.
$0407 54279 PMBASE
Most-srgniflcant byte of the player/missile base address.
$0408 54280
Unused.
SD409 54281 CHBASE
Text character bit map base address.
$D40A 54282 WSYNCH
Wait-for- horizontal sync flag.
$D40B 54283 VCOUNT
Vertical-scan line counter.
$D40C 54284 PENH
Horizontal position of light pen.
$0400 54285 penv
Vertical position of light pen.
$D40E 54286 NMIEN
Enable nonmaskable interrupt.
$p40F 54287 NMIRES/NMIST
Clear mterrupt-request. reset any nonmaskable interrupts
and return current interrupt status.
SD410-$041F 54288-54303
Ouplicate of $0400-$D40F 54272-54287
OPERATING SYSTEM ROM AREA: 55296-65535
The uppermost section of the ATARI memory map is
devoted to ROM operations for the operating system,
itself. This section is common to both the 800 and 400
systems, and it is used whether a BASIC cartridge is
installed or not.
346
Chart 8-12 outlines the major functions and entry-point
addresses.
Chart 8-12. Operating System
ROM Area: 55296-65535
$D800-$DFFF 55296-57393
Floating-point arithmetic.
$E00O-$E3FF 57344-58367
Internal character set (see Appendix C2).
$E400-$E40F 58368-58383
Editor vectors.
$E410-$E41F 58384-58399
Screen vectors.
$E420-SE42F 58400-58415
Keyboard vectors.
$E430-$E43F 58416-58431
Printer vectors.
SE440-$E44F 58432-58447
Cassette vectors.
$E450-$E4A5 58448-58533
Jump and initial RAM vectors.
$EA6-$E6D4 58534-59092
Central I/O (CIO) handler addresses.
$E6D5-$E943 59093-59715
Interrupt handler addresses.
$E944-$EDE9 59716-60905
Serial I/O (SIC) routines.
$EDEA-$EE77 60906-61047
Disk handler routines.
$EE78-$EF40 61048-61248
Printer handler routines.
$EF41-$F0E2 61249-61666
Cassette handler routines.
347
Chart 8-12— cont. Operating System
ROM Area: 55296-65535
$F0E3-$F3E3 61667-62435
Monitor handler routines.
$F3E4-$FFFF 62436-65535
Display and keyboard handler routines.
348
Chapter 9
The 6502 Instruction Set
The hallmarks of machine-language programs are higher
operating speeds and more efficient use of available RAM
space. There are two different ways to work with machine-
language programs with the ATARI system and, indeed,
most personal computers.
One technique uses a BASIC program to POKE decimal
versions of the machine instructions and data into a speci-
fied area of memory (also specified in a decimal format),
and then execute the routines from BASIC by means of
the USR command.
An alternative approach is to take advantage of the
ATARI Assembler Editor software. The programmer can
write, enter, edit, and debug machine-language programs
in a source code, or assembly language, format. Although
source programs generally use a hexadecimal data and
addressing format, the Assembler Editor package offers
the option of working with decimal values as well.
It is beyond the scope of this book to deal with pro-
gramming procedures for the 6502 microprocessor. Any
good book on the subject of 6502 programming or,
indeed, ATARI'S Assembler Editor Manual can be of valu-
able help in this regard.
Table 9-1 summarizes the 6502 instruction set, showing
the op codes in both decimal and hexadecimal forms.
349
Table 9-1 . Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
$00
BRK
Implied
$01
1
ORA
(indirect, x)
$02
2
not used
$03
3
not used
$04
4
not used
$05
5
ORA
zero page
$06
6
ASL
zero page
$07
7
not used
$08
8
PHP
implied
$09
9
ORA
immediate
$0A
10
ASL
accumulator
$0B
11
not used
$0C
12
not used
$0D
13
ORA
absolute
$0E
14
ASL
absolute
$0F
15
not used
$10
16
BPL
relative
$11
17
ORA
(indirect),Y
$12
18
not used
$13
19
not used
$14
20
JSR
$15
21
ORA
zero page.X
$16
22
ASL
zero page.X
$17
23
not used
$18
24
CLC
implied
$19
25
ORA
absolute.Y
$1A
26
not used
$1B
27
not used
$1C
28
not used
$1D
29
ORA
absolute.X
$1E
30
ASL
absolute.X
$1F
31
not used
350
Table 9-1— cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Op Code
Dec
Op Code
Mnemonic
$20
32
JSR
absolute
$21
33
AND
(indirect.X)
$22
34
not used
$23
35
not used
$24
36
BIT
zero page
$25
37
AND
zero page
$26
38
ROL
zero page
$27
39
not used
$28
40
PLP
implied
$29
41
AND
immediate
$2A
42
ROL
accumulator
$2B
43
not used
$2C
44
BIT
absolute
$2D
45
AND
absolute
$2E
46
ROL
absolute
$2F
47
not used
$30
48
BMI
relative
$31
49
AND
{indirect),Y
$32
50
not used
$33
51
not used
$34
52
not used
$35
53
AND
zero page.X
$36
54
ROL
zero page.X
$37
55
not used
$38
56
SEC
implied
$39
57
AND
absolute.Y
$3A
58
not used
$38
59
not used
$3C
60
not used
$3D
61
AND
absolute.X
$3E
62
ROL
absolute.X
$3F
63
not used
351
Table 9-1— cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
$40
64
RTI
implied
$41
65
EpR
(indirect,X)
$42
66
not used
$43
67
not used
$44
68
not used
$45
69
EOR
zero page
$46
70
LSR
zero page
$47
71
not used
$48
72
PHA
implied
$49
73
EOR
Immediate
$4A
74
LSR
accumulator
$4B
75
not used
$4C
76
JMP
absolute
$4D
77
EOR
absolute
$4E
78
LSR
absolute
$4F
79
not used
$50
80
BVC
relative
$51
81
EOR
(indirect),Y
S52
82
not used
$53
83
not used
$54
84
not used
$55
85
EOR
zero page.X
$56
86
LSR
zero page.X
$57
87
not used
S58
88
CLI
implied
$59
89
EOR
absolute, Y
$5A
90
not used
$5B
91
not used
$5C
92
not used
$50
93
EOR
absolute.X
$5E
94
LSR
absolute.X
$5F
95
not used
352
Table 9-1— cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
$60
96
RTS
implied
$61
97
ADC
(indirect.X)
$62
98
not used
$63
99
not used
$64
100
not used
$65
101
ADC
zero page
$66
102
ROR
zero page
$67
103
not used
$68
104
PLA
implied
$69
105
ADC
immediate
$6A
106
ROR
accumulator
$6B
107
not used
$6C
108
JMP
indirect
$6D
109
ADC
absolute
$6E
110
ROR
absolute
$6F
111
not used
$70
112
BVS
relative
$71
113
ADC
(indirect),Y
$72
114
not used
$73
115
not used
$74
116
not used
$75
117
ADC
zero page.X
$76
118
ROR
zero page.X
$77
119
not used
$78
120
SEI
implied
$79
121
ADC
absolute.Y
$7A
122
not used
$7B
123
not used
$7C
124
not used
$7D
125
ADC
absolute,X
$7E
126
ROR
absolute.X
$7F
127
not used
353
Table 9-1 — cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
$80
128
BCS
relative
$81
129
STA
(indirect.X)
$82
130
not used
$83
131
not used
$84
132
STY
zero page
$85
133
STA
zero page
$86
134
STX
zero page
$87
135
not used
$88
136
DEY
implied
$89
137
not used
$8A
138
TXA
implied
$8B
139
not used
$8C
140
STY
absolute
$8D
141
STA
absolute
$8E
142
STX
absolute
$8F
143
not used
$90
144
BCC
relative
$91
145
STA
(indirect),Y
$92
146
not used
$93
147
not used
$94
148
STY
zero page.X
$95
149
STA
zero page.X
$96
150
STX
zero page.Y
S97
151
not used
$98
152
TYA
implied
$99
153
STA
absolute.Y
$9A
154
TXS
implied
$9B
155
not used
$9C
156
not used
$9D
157
STA
absolute.X
$9E
158
not used
$9F
159
not used
354
Table 9-1 — cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
SAO
160
LDY immediate
$A1
161
LDA (indirect.X)
$A2
162
LDX immediate
$A3
163
not used
$A4
164
LDY zero page
$A5
165
LDA zero page
$A6
166
LDX zero page
$A7
167
not used
$A8
168
TAY implied
$A9
169
LDA immediate
$AA
170
TAX implied
$AB
171
not used
SAC
172
LDY absolute
SAD
173
LDA absolute
SAE
174
LDX absolute
SAF
175
not used
SBO
176
BCS
SB1
177
LDA (indirect),Y
SB2
178
not used
$B3
179
not used
SB4
180
LDY zero page.X
SB5
181
LDA zero page.X
SB6
182
LDX zero page.Y
SB7
183
not used
SB8
184
CLV implied
$B9
185
LDA absolute.Y
SBA
186
TSX implied
SBB
187
not used
SBC
188
LDY absolute.X
SBD
189
LDA absolute.X
SBE
190
LDX absolute.Y
SBF
191
not used
355
Table 9-1— cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
$C0
192
CPY
immediate
$C1
SC2
193
194
CMP
(indirect.X)
not used
$C3
195
not used
$C4
196
CPY
zero page
$C5
197
CMP
zero page
SC6
198
DEC
zero page
$C7
199
not used
SC8
200
INY
implied
SC9
201
CMP
immediate
$CA
202
DEX
Implied
$CB
203
not used
$CC
204
CPY
absolute
SCD
205
CMP
absolute
$CE
206
DEC
absolute
$CF
207
not used
$D0
208
BNE
relative
$D1
209
CMP
(indirect),Y
$D2
210
not used
$D3
211
not used
$D4
212
not used
$D5
213
CMP
zero page.X
$D6
214
DEC
zero page.X
$D7
215
not used
SD8
216
CLD
implied
$D9
217
CMP
absolute.Y
$DA
218
not used
$DB
219
not used
$DC
220
not used
$DD
221
CMP
absolute.X
$DE
222
DEC
absolute, X
SDF
223
not used
356
Table 9-1— cont. Summary of the 6502 Instruction
Set as Organized by Op Codes
Hex
Dec
Op Code
Op Code
Mnemonic
$E0
224
CPX
immediate
$E1
225
SBC
(indirect.X)
$E2
226
not used
$E3
227
not used
$E4
228
CPX
zero page
$E5
229
SBC
zero page
$E6
230
INC
zero page
$E7
231
not used
$E8
232
INX
implied
$E9
233
SBC
immediate
SEA
234
NOP
implied
$EB
235
not used
$EC
236
CPX
absolute
$ED
237
SBC
absolute
SEE
238
INC
absolute
SEP
239
not used
SFO
240
BEQ
relative
SFI
241
SBC
(indirect),Y
$F2
242
not used
SF3
243
not used
SF4
244
not used
SF5
245
SBC
zero page.X
SF6
246
INC
zero page.X
SF7
247
not used
$F8
248
SED
Implied
$F9
249
SBC
absolute, Y
SFA
250
not used
SFB
251
not used
SFC
252
not used
SFD
253
SBC
absolute.X
SFE
254
INC
absolute, X
SFF
255
not used
357
Fig. 9-1 illustrates the organization of registers within
the 6502 microprocessor.
15
I
REGISTER BITS
7
I
PCH
PCL
1
s
ACCUMULATOR
X REGISTER
Y REGISTER
PROGRAM COUNTER
STACK POINTER
PROCESSOR STATUS REGISTER
Fig. 9-1 . The 6502 internal registers.
The remainder of this chapter is devoted to a detailed
version of the instructions set. The materia! is arranged by
instruction mnemonics, and in alphabetical order. Aste-
risks shown under the heading. Status register, indicate
status-register bits that are affected by the operation.
358
ADC ADD memory to accumulator with carry
Operation: A+M+C— A, C
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
ADC #Oper
69
105
2
Zero Page
ADC Oper
65
101
2
Zero Page.X
ADC Oper.X
75
117
2
Absolute
ADC Oper
6D
109
3
Absolute.X
ADC Oper.X
7D
125
3
Absolute, Y
ADC Oper,Y
79
121
3
(Indirect.X)
ADC (Oper.X)
61
97
2
(lndlrect),Y
ADC (Oper),Y
71
113
2
AND Logically AND memory with accumulator
Operation: A"M— A
Status register (P)
N Z C I D
Addressing
Assembly Language
Hex
Dec
Bytes
IMode
Format
Op Code
Op Code
Immediate
AND #Oper
29
41
2
Zero Page
AND Oper
25
37
2
Zero Page,X
AND Oper.X
35
53
2
Absolute
AND Oper
2D
45
3
Absolute.X
AND Oper.X
3D
61
3
Absolute.Y
AND Oper.Y
39
57
3
(Indirect.X)
AND (Oper.X)
21
33
2
(Indirect).Y
AND (Oper).Y
31
49
2
359
ASL Shift memory or accumulator 1 bit to the left
Operation:
fcl*^7l6l5l4l3l?liTnl^
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Accumulator
ASL A
OA
10
1
Zero Page
ASL Oper
06
6
2
Zero Page.X
ASL Oper.X
16
22
2
Absolute
ASL Oper
OE
14
3
Absolute.X
ASL Oper.X
IE
30
3
BCC Branch on carry clear
Operation: Branch if C=0
N
Status register (P)
Z C 1 D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BCC Oper
90
144
2
BCS Branch on carry set
Operation: Branch on C=1
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BCS Oper
80
128
2
360
BEQ Branch on result zero
Operation: Branch if Z=1
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BEQ Oper
FO
240
2
BIT Test memory bits with accumulator
Operation: A*M, M7— N, Mg— V
Status register (P)
N
M,
Z C
*
I
D V
- M.
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Zero Page
Absolute
BIT Oper
BIT Oper
24
2C
36
44
2
3
BMI Branch on result minus
Operation: Branch if N=1
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BMI Oper
30
48
2
361
BNE Branch on result not zero
Operation: Branch if Z=0
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BNE Oper
DO
208
2
BPL Branch on result plus
Operation: Branch if N=0
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BPL Oper
10
16
2
BRK Forced break
Operation: Interrupt, PC+2JPi
Status register (P)
N Z C I D V
- - - 1 - -
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
BRK
00
1
362
BVC Branch on overflow clear
Operation: Branch if V=0
Status register (P)
N Z C I D V
Addressing
Mode
Relative
Assembly Language
Format
BVC Oper
Hex
Op Code
50
Dec
Op Code
80
Bytes
BVS Branch on overflow set
Operation: Branch if V=1
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Relative
BVS Oper
70
112
2
CLC Clear carry flag
Operation: O^C
Status register (P)
N
z c
1 D V
- -
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
CLC
18
24
1
363
CLD Clear decimal arithmetic mode
Operation: O^D
Status register (P)
N
z c
-
1 D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
CLD
D8
216
1
CLI Clear interrupt disable bit
Operation: 0^1
Status register (P)
N Z C I D V
- - - - -
Addressing
Mode
Implied
Assembly Language
Format
CLI
Hex
Op Code
58
Dec
Op Code
88
Bytes
CLV Clear overflow flag
Operation: O^V
Status register (P)
Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
CLV
B8
184
1
364
CMP Compare memory and accumulator
Operation: A - M
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
CMP #0per
C9
201
2
Zero Page
CMP Oper
C5
197
2
Zero Page.X
CMP Oper.X
D5
213
2
Absolute
CMP Oper
CD
205
3
Absolute.X
CMP Oper.X
DD
221
3
Absolute.Y
CMP Oper.Y
D9
217
3
(Indirect.X)
CMP (Oper.X)
CI
193
2
(lndirect),Y
CMP (Oper).Y
D1
209
2
CPX Compare memory and X register
Operation: X - M
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Immediate
Zero Page
Absolute
CPX #Oper
CPX Oper
CPX Oper
EG
E4
EC
224
228
236
2
2
3
365
CPY Compare memory and Y register
Operation: Y - M
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Immediate
Zero Page
Absolute
CPY #Oper
CPY Oper
CPY Oper
CO
C4
CC
192
196
204
2
2
3
DEC Decrement memory by 1
Operation: M-1 — M
Status register (P)
N Z C
* *
I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Zero Page
DEC Oper
C6
198
2
Zero Page.X
DEC Oper.X
D6
214
2
Absolute
DEC Oper
CE
206
3
Absolute.X
DEC Oper.X
DE
222
3
DEX Decrement X register by 1
Operation: X-1 —X
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
DEX
CA
202
1
366
DEY Decrement Y register by 1
Operation: Y-1 -Y
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
DEY
88
136
1
EOR Logicalply EXCLUSiVE-OR memory and accumulator
Operation: AvM— A
Status register (P)
N Z C 1 D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
EOR #Oper
49
73
2
Zero Page
EOR Oper
45
69
2
Zero Page.X
EOR Oper,X
55
85
2
Absolute
EOR Oper
4D
77
3
Absolute, X
EOR Oper.X
5D
93
3
Absolute.Y
EOR Oper.Y
59
89
3
(Indirect.X)
EOR (Oper.X)
41
65
2
{lndirect),Y
EOR (Oper),Y
51
81
2
367
INC Increment memory by 1
Operation: M+1 — M
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Zero Page
INC Oper
E6
230
2
Zero Page.X
INC Oper.X
F6
246
2
Absolute
INC Oper
EE
238
3
Absolute.X
INC Oper.X
FE
254
3
INX Increment X register by 1
Operation: X+1 -^ X
Status register (P)
N
*
Z C
*
I D V
Addressing
IMode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
INX
E8
232
1
INY Increment Y register by 1
Operation: Y+1 - Y
Status register (P)
N
*
z c
*
1 D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
INY
C8
200
1
368
JMP Unconditional jump to new address
Operation: (PC+1)-PCL
(PC+2) - PCH
Status register (P)
N Z C 1 D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Absolute
Indirect
JMP Oper
JMP (Oper)
4C
6C
76
108
3
3
JSR Jump to new address and save return address
Operation: PC+2 I
(PC+1)-PCL
(PC+2) - PCH
N
Status register (P)
Z C 1 D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Absolute
JSR Oper
20
32
3
369
LDA Load the accumulator with memory
Operation: M ^ A
Status register (P)
N
Z C
1 D V
*
*
- - -
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
LDA #Oper
A9
169
2
Zero Page
LDA Oper
A5
165
2
Zero Page.X
LDA Oper.X
B5
181
2
Absolute
LDA Oper
AD
173
3
Absolute.X
LDA Oper.X
BD
189
3
Absolute.Y
LDA Oper.Y
89
185
3
(Indirect.X)
LDA (Oper.X)
A1
161
2
(lndlrect),Y
LDA (Oper),Y
81
177
2
LDX Load X register with memory
Operation: M — X
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
LDX #Oper
A2
162
2
Zero Page
LDX Oper
A6
166
2
Zero Page.Y
LDX Oper.Y
86
182
2
Absolute
LDX Oper
AE
174
3
Absolute.Y
LDX Oper.Y
8E
190
3
370
LDY Load Y register with memory
Operation: M — Y
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
LDY #Oper
AO
160
2
Zero Page
LDY Oper
A4
164
2
Zero Page.X
LDY Oper,X
B4
180
2
Absolute
LDY Oper
AC
172
3
Absolute.X
LDY Oper.X
BC
188
3
LSR Shift memory or accumulator 1 bit to right
Status register (P)
N
z
*
c
*
I D V
Addressing
Assembly Language
Hex
Dec
Bytes
IMode
Format
Op Code
Op Code
Accumulator
LSR A
4A
74
1
Zero Page
LSR Oper
46
70
2
Zero Page.X
LSR Oper.X
56
86
2
Absolute
LSR Oper
4E
78
3
Absolute.X
LSR Oper.X
5E
94
3
371
NOP No operation
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
NOP
EA
234
1
ORA Logically OR memory and accum
Operation: A V M — A
ulator
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
ORA #Oper
09
9
2
Zero Page
ORA Oper
05
5
2
Zero Page.X
ORA Oper.X
15
21
2
Absolute
ORA Oper
OD
13
3
Absolute.X
ORA Oper.X
ID
29
3
Absolute.Y
ORA Oper.Y
19
25
3
(Indirect.X)
ORA (Oper.X)
01
1
2
(Indirect).Y
ORA (Oper),Y
11
17
2
PHA Push accumulator to top of stack
Operation: A \
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
PHA
48
72
1
372
PHP Push status register to top of stack
Operation: P 1
Status register (P)
N Z C 1 D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
PHP
08
8
1
PLA Pull top of stack to accumulator
Operation: A t
Status register (P)
N Z C I D V
Addressing
1\Mode
Implied
Assembly Language
Format
PLA
Hex
Op Code
68
Dec
Op Code
104
Bytes
PLP Pull top of Stack to status register
Operation: P t
Status register (P)
From Stack
Addressing
Mode
Implied
Assembly Language
Format
PLP
Hex
Op Code
28
Dec
Op Code
40
Bytes
373
ROL Rotate memory or accumulator 1 bit to left
Operation: I
M7l6l5l4l3blilnHrlJ
Status register (P)
N Z C I D V
Addressing
Mode
Accumulator
Zero Page
Zero Page.X
Absolute
Absolute.X
Assembly Language
Hex
Format
Op Code
ROL A
2A
ROL Oper
26
ROL Oper.X
36
ROL Oper
2E
ROL Oper.X
3E
Dec
Op Code
42
38
54
46
62
Bytes
ROR Rotate memory or accumulator 1 bit to right
Operation: I
HcH7l6l5l4|3l2lllflH
Status register (P)
N Z C I D V
Addressing
Mode
Accumulator
Zero Page
Zero Page.X
Absolute
Absolute.X
Assembly Language
Format
ROR
ROR
ROR
ROR
ROR
A
Oper
Oper.X
Oper
Oper.X
Hex
Dec
Bytes
Op Code
Op Code
6A
106
1
66
102
2
76
118
2
6E
110
3
7E
126
3
374
RTI Return
Operation:
from interrupt
Pf PC t
Status register (P)
From Stack
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
RTI
40
64
1
RTS Return from subroutine
Operation: PCt,PC-1-PC
N
Status register (P)
Z C 1 D V
Addressing
IVIode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
RTS
60
96
1
SBC Subtract memory from accumulator with borrow
Operation: A-M-C — A
Status register (P)
N Z C I D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Immediate
SBC #Oper
E9
233
2
Zero Page
SBC Oper
E5
229
2
Zero Page,X
SBC Oper,X
F5
245
2
Absolute
SBC Oper
ED
237
3
Absoiute.X
SBC Oper.X
FD
253
3
Absolute, Y
SBC Oper.Y
F9
249
3
(Indirect.X)
SBC (Oper.X)
El
225
2
(lndirect),Y
SBC (Oper),Y
F1
241
2
375
SEC Set carry flag
Operation: 1 — C
Status register (P)
N Z C I D V
- - 1 - - .
Addressing
Mode
Implied
Assembly Language
Format
SEC
Hex
Op Code
38
Dec
Op Code
56
Bytes
SED Set decimal arithmetic mode
Operation: 1 ^ D
Status register (P)
N Z C I D
- - - - 1
Addressing
Mode
Implied
Assembly Language
Format
SED
Hex
Op Code
F8
Dec
Op Code
248
Bytes
SEI Set disable interrupt flag
Operation: 1 -> I
Status register (P)
N Z C I D V
- - - 1 - -
Addressing
Mode
Implied
Assembly Language
Format
SEI
Hex
Op Code
78
Dec
Op Code
120
Bytes
376
STA Store accumulator in memory
Operation: A -* M
Status register (P)
N Z C 1 D V
Addressing
Assembly Language
Hex
Dec
Bytes
Mode
Format
Op Code
Op Code
Zero Page
STA Oper
85
133
2
Zero Page.X
STA Oper.X
95
149
2
Absolute
STA Oper
8D
141
3
Absolute.X
STA Oper.X
9D
157
3
Absolute.Y
STA Oper.Y
99
153
3
(lndirect,X)
STA (Oper.X)
81
129
2
(lndlrect),Y
STA (Oper).Y
91
145
2
STX Store X register in memory
Operation: X — M
Status register (P)
N Z C 1 D V
Addressing
(Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Zero Page
Zero Page.Y
Absolute
STX Oper
STX Oper.Y
STX Oper
86
96
8E
135
150
142
2
2
3
STY Store Y register in memory
Operation: Y -* M
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Zero Page
Zero Page.X
Absolute
STY Oper
STY Oper.X
STY Oper
84
94
8C
132
148
140
2
2
3
377
TAX Transfer accumulator to X register
Operation: A — X
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
TAX
AA
170
1
TAY Transfer accumulator to Y register
Operation: A ^ Y
Status register (P)
N Z C I D V
Addressing
IVIode
Implied
Assembly Language
Format
TAY
Hex
Op Code
A8
Dec
Op Code
168
Bytes
TSX Transfer stack pointer to X register
Operation: S — X
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
TSX
BA
186
1
378
TXA Transfer X register to accumulator
Operation: X — A
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
TXA
8A
138
1
TXS Transfer X register to stack pointer
Operation: S — X
Status register (P)
N Z C I D V
* *
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
TSX
BA
186
1
TYA Transfer Y register to accumulator
Operation: Y — A
Status register (P)
N Z C I D V
Addressing
Mode
Assembly Language
Format
Hex
Op Code
Dec
Op Code
Bytes
Implied
TYA
98
152
1
379
Appendix A
Number-System
Base Conversions
Just about any computer (certainly the ATARI system) is
essentially a binary machine; the 6502 microprocessor
does all of its control, arithmetic, and logic operations in a
base 2, or binary, number system. And it so happens that
the 6502 works with 8-bit binary numbers — a full byte of
them.
People do not think and work with binary numbers very
well, however. Such numbers, being made up exclusively
of Os and Is, are very cumbersome. One alternative to
purely binary representations of numbers is hexadecimal
numbers. The hexadecimal (base 16) number system looks
at binary numbers in groups of four; every group of four
binary numbers (sometimes called a nibble) can be re-
presented by a single hexadecimal number. So, instead of
having to work with strings of eight Os and Is in base-2
binary, it is possible to work with just two hexadecimal
characters.
While, indeed, many machine-language programmers
can learn to work with hexadecimal numbers with great
proficiency, the general population still prefers the ordi-
nary decimal (base 10) number system. ATARI engineers
were aware of that fact, so they designed the ATARI BASIC
ROM cartridge exclusively around the decimal number
system.
381
As long as one works with ATARI BASIC in its most
elementary fashion— doing no special addressing or
machine-language work — there is no need to be aware of
hexadecimal or binary numbers. But hexadecimal num-
bers become quite helpful when doing extensive machine-
language programming.
Thus, programmers who are working their way deeper
and deeper into the ATARI system will find themselves
having to make conversions between decimal and hex-
adecimal numbers and, eventually, between binary and
hexadecimal numbers. The purpose of this appendix is to
make such conversion tasks as simple as possible.
There are many ways to approach the conversions
between these three different systems; the following are
the most straightforward.
HEXADECIMAL-TO-DECIMAL CONVERSIONS
In the ATARI system, data is carried as a 1-byte (two-
hexadecimal-number) code. Addresses are carried as 1-
byte codes for the zero-page memory and as 2-byte codes
for the remainder of the usable memory space. Table A-1
can be very helpful for translating hexadecimal numbers
into their decimal counterparts. This sort of situation often
arises when one is writing programs in both BASIC and
machine language.
The table can be used for converting up to four hexadec-
imal places, or nibbles, to their counterpart. Notice that
there are four major columns, labeled 1 through 4. These
column numbers represent the relative position of the
hexadecimal characters as they are usually written, with
the least-significant nibble on the right and the most-
significant nibble on the left.
382
Table A-1 . Hexadecimal/Decimal Conversion Table
MSB
LSB
4
3
2
1
HEX
DEC
HEX
DEC
HEX
DEC
HEX
DEC
1
4096
1
256
1
16
1
1
2
8192
2
512
2
32
2
2
3
12288
3
768
3
48
3
3
4
16384
4
1024
4
64
4
4
5
20480
5
1280
5
80
5
5
6
24576
6
1536
6
96
6
6
7
28672
7
1792
7
112
7
7
8
32768
8
2048
8
128
8
8
9
36864
9
2304
9
144
9
9
A
40960
A
2560
A
160
A
10
B
45056
B
2816
B
176
B
11
C
49152
C
3072
C
192
C
12
D
53248
D
3328
D
208
D
13
E
57344
E
3584
E
224
E
14
F
61440
F
3840
F
240
F
15
To see how the table works, suppose that you want to
convert the hexadecimal value $1A3F into decimal. The
first character on the left takes a decimal equivalent
shown in column 4 — 4096. The second character from the
left takes on the value from column 3 — 2560. The last two
figures get their decimal equivalents from columns 2 and
1 — 48 and 15, respectively. Then, to get the true decimal
value, add those decimal equivalents: 4096 + 2560 + 48 +
15, or 6719. In other words, $1A3F is equal to 6719 in
decimal.
If you are converting a two-place hexadecimal number,
just use columns 2 and 1. Hexadecimal $C3, for instance, is
equal to 192 + 3, or decimal 195.
Table A-1 is adequate for hexadecimal-to-decimal con-
versions for all the usual sort of work on the ATARI
system.
383
DECIMAL-TO-HEXADECIMAL CONVERSIONS
When working back and forth between BASIC and machine-
language routines, it is often necessary to convert decimal
data and addresses into hexadecimal notation. Table A-1
comes to the rescue again. The procedure is a rather
straightforward one, but it involves several steps.
Suppose, for example, that you want to convert decimal
65 into its hexadecimal counterpart. First, find the decimal
number on the table that is equal to, or less than, the
desired decimal number. The decimal number in this
example is 65, and the closest value less than 65 is 64. The
64 is equivalent to a hexadecimal $4 in column 2. Thus the
most-significant number in the hexadecimal representa-
tion is 4.
Next, subtract that 64 from the number that you are
working with: 65 - 64 = 1. Then look up the hexadecimal
value of the 1 in the next-lower column of the table-
column 1 in this instance. The hexadecimal version of that
number is $1. Putting together those two hexadecimal
characters, you get a $41. Indeed, decimal 65 translates
into hexadecimal $41.
By way of a somewhat more involved conversion, sup-
pose that you must convert decimal 19314 into hexadec-
imal notation.
Looking through the columns of decimal numbers in
the table, you find that 16384 is the next-lower value; it
translates into hexadecimal $4 in column 4. So you are
going to end up with a four-digit hexadecimal number,
with the digit on the left being a 4.
To get the next-lower place value, subtract the table
value 16384 from 19314: 19314 - 16384 = 2930. The next
lower decimal value in this case is 2816 from column 3;
that turns up a $B as the next hexadecimal character. So
far, the number is $4B.
384
Now subtract the table value 2816 from 2930: 2930 -
2816 = 114. The next-lower decimal value from column 2
is 112, and its hexadecimal counterpart is 7. And to this
point, the hexadecimal number is $4B7.
Finally, subtract the table value 112 from 114. 114 - 112 =
2. From column 1, decimal 2 is the same as hexadecimal $2;
so the final hexadecimal character is $2.
Putting all this together, it turns out that decimal 19314 is
the same as hexadecimal $4B72. Fig. A-1 summarizes the
operation.
HEXADECIMAL
EQUIVALENT
4 B 7 2
i t 4 '
DECIMAL
NUMBER
- COLUMN 4-:
19314-
- 16384
2930 COLUMN 3-
-2816
114 COLUMN 2-
112
2 COLUMN 1 -
19314 (DECIMAL) = $4672 (HEXADECIMAL)
♦ column numbers REFER TO TABLE A1
Fig. A-1 . Converting decimal values to hexadecimal values.
CONVENTIONAL DECIMAL TO 2-BYTE DECIMAL
FORMAT
When POKEing addresses as 2-byte numbers into memory,
it is necessary to convert the address to be affected into a
2-byte format, in decimal, such an operation isn't easy, but
it is all a part of setting up address locations in decimal-
oriented BASIC.
385
By way of an example, suppose that you are to load a
2-byte version of decimal address 1234 into memory
addresses 16787 and 16788. That number to be stored,
1234, is too large for either of those 1-byte addresses, so it
has to be broken up into two parts: one for each of the
address locations.
Before a decimal number can be divided into a 2-byte
version, it must be converted into hexadecimal form.
Using the decimal-to-hexadecimal conversion described
in the previous section, you find that decimal 1234 is equal
to hexadecimal $04D2.
Next, you divide that hexadecimal version of the num-
ber into two bytes: the most-significant byte (MSB) is $04,
and the least-significant byte (LSB) is $D2. Divided that
way, you end up with two 1-byte hexadecimal values: $04
and $D2.
Finally, convert those two sets of hexadecimal numbers
into their decimal equivalents, treating them as two sepa-
rate hexadecimal values. Thus $04 converts to decimal 4,
and $D2 converts to 210.
The 2-byte version of decimal 1234 is thus 4 and 210,
with 4 being the MSB and 210 being the LSB.
That takes care of the conversion of an ordinary decimal
number into a 2-byte version, also in decimal. Now you
must POKE these numbers into decimal addresses 16787
and 16788.
If you place the LSB of the 2-byte number into the
lower-numbered address, the BASIC operation for satisfy-
ing the requirements of the example looks like this:
POKE 16787, 210 : POKE 16788,4
No, it isn't a simple procedure to convert an ordinary
decimal number into a 2-byte decimal format, but it's the
price that must be paid for working with a byte-oriented
machine in a decimal-oriented BASIC language.
386
TWO-BYTE DECIMAL TO CONVENTIONAL DECIMAL
FORMAT
Suppose that you are analyzing a machine-language rou-
tine that is presented in a decimal-oriented, BASIC format.
Under that condition, a 2-byte address appears as a set of
two decimal numbers; if you want to get that pair of
numbers into a conventional decimal format, you have to
play with them a bit.
Consider an instance where 223 turns up as the LSB in
decimal, and 104 is the MSB. What address, or 2-byte
decimal number, do they represent?
First, convert both sets of numbers into their hexadec-
imal counterparts; decimal 223 =$DF, and decimal 104 =
$68. Since $DF is the MSB and $68 is the LSB, the overall
hexadecimal representation of that 2-byte decimal format
is $DF68.
All that remains to be done is to convert that hexadec-
imal number into its full decimal counterpart:
$DF68 = 24567 + 2048 + 208 + 15 = 26849
That's it — the conventional representation of the origi-
nal 2-byte decimal values. The combination of decimal
numbers 223 and 104 actually points to decimal 26849.
BINARY-TO-DECIMAL CONVERSION
In practice, most binary-to-decimal conversions are car-
ried out with 1-byte (or 8-bit) binary numbers, although
there are occasions when it is necessary to do the conver-
sion from 2-byte (16-bit) numbers.
Fig. A-2 shows the breakdown of an 8-bit binary num-
ber. The positions are labeled through 7, with zero indi-
cating the least-significant bit position. Each of those 8-bit
locations contains either a or a 1.
387
MSE
LSB
7
6
5
4
3
2
1
Fig. A-2. An 8-bit binary number.
Suppose that you want to POKE 01101011. But you have
to use a decimal version of that binary number from
BASIC. Here is how to go about determining that decimal
version.
First, multiply the or 1 in each bit location by 2n,
where n is the bit place in each case. Then simply add the
results. (See the example in Fig. A-3.)
1 BINARY
-»-1x20=1x1=1
-^1 X21 = 1 x2 = 2
-^0x22 = 0x4 =
-♦■1x23 = 1 x8 = 8
-»-0x2< = Ox16 = O
-^1x25 = 1x32 = 32
-^1x26 = 1x64 = 64
-*-0x27 = 0x128 = 0_
107 TOTAL
01101011 BINARY = 107 DECIMAL
Fig. A-3. Converting binary values to decimal values.
The same idea applies to converting 16-bit binary to a
decimal equivalent. The place values run from to 15 in
that case, and Table A-2 can help you determine those
powers of 2.
BINARY-TO-HEXADECIMAL CONVERSION
Converting a binary number into a hexadecimal format is
perhaps the simplest of all the conversion operations. All
you have to do is group the binary number into sets of 4
bits each, beginning with the least-significant bit, and then
find the hexadecimal value for each group. Table A-3
helps with the latter operation.
388
Table A-2. Powers of 2
n
2"
1
1
2
2
4
3
8
4
16
5
32
6
64
7
128
8
256
9
512
10
1024
11
2048
12
4096
13
8192
14
16384
15
32768
Table A-3. Binary/Hexadecimal Conversion Table
Binary
Hex
0000
$0
0001
SI
0010
$2
0011
$3
0100
S4
0101
$5
0110
$6
0111
$7
1000
$8
1001
$9
1010
$A
1011
$B
1100
$C
1101
$D
1110
SE
1111
SF
Suppose the binary number is 10011101. There are two
sets of 4 bits (or nibbles) here, 1001 and 1101. The hexadec-
imal equivalent is 9 for the first set, and D for the second
set, as Table A-3 shows. Therefore, the hexadecimal ver-
sion of that 8-bit binary number is $9D.
389
The same procedure works equally well for 16-bit
numbers; the only difference is that you end up with four
hexadecimal characters instead of just two.
HEXADECIMAL-TO-BINARY CONVERSION
Converting a hexadecimal number to its binary form is a
simple matter of applying Table A-3 to change each hex-
adecimal character into the appropriate groups of 4 binary
bits.
Example: Convert address $404D into a binary format.
According to the table, that hexadecimal number can be
represented as 0100 0000 0100 1101.
DECIMAL-TO-BINARY CONVERSION
There are several commonly cited algorithms for mathe-
matically converting any decimal number into its binary
format. But it is simpler in the long run, and probably
more accurate, to use a two-step procedure.
The general idea is to convert the decimal number into
its hexadecimal counterpart as described earlier in this
appendix. Then convert the hexadecimal characters into
their binary versions as described in the previous section.
Example: Convert 1234 decimal into binary. First, as de-
scribed earlier, calculate the hexadecimal version of
decimal 1234. Your answer should come out to be $04D2.
And that hexadecimal number, expressed in binary (from
Table A-3) is 0000 0100 1101 0010. Thus 1234 is equal to
binary 10011010010. You may include the five leading
zeros if you wish.
390
A COMPLETE CONVERSION TABLE FOR DECIMAL
0-255
For readers who have no heart for doing a lot of number
conversions. Table A-4 can come to the rescue. It is
impractical to tabulate the conversions for the entire
memory range of the ATARI system, but the range of
values shown here will apply to any data byte.
Table A-4. Decimal/Hexadecimal/Binary Table
for Decimal Values Through 255
DEC
HEX
BIN
DEC
HEX
BIN
$00
00000000
32
$20
00100000
1
SOI
00000001
33
$21
00100001
2
$02
00000010
34
$22
00100010
3
$03
00000011
35
$23
00100011
4
$04
00000100
36
$24
00100100
5
$05
00000101
37
$25
00100101
6
$06
00000110
38
$26
00100110
7
$07
00000111
39
$27
00100111
8
$08
00001000
40
$28
00101000
9
$09
00001001
41
$29
00101001
10
$0A
00001010
42
$2A
00101010
11
$0B
00001011
43
$28
00101011
12
$0C
00001100
44
$2C
00101100
13
$0D
00001101
45
$2D
00101101
14
$0E
00001110
46
$2E
00101110
15
$0F
00001111
47
$2F
00101111
16
$10
00010000
48
$30
00110000
17
$11
00010001
49
$31
00110001
18
$12
00010010
50
$32
00110010
19
$13
00010011
51
$33
00110011
20
$14
00010100
52
$34
00110100
21
$15
00010101
53
$35
00110101
22
$16
00010110
54
$36
00110110
23
$17
00010111
55
$37
00110111
24
$18
00011000
56
$38
00111000
25
$19
00011001
57
$39
00111001
26
$1A
00011010
58
$3A
00111010
27
$18
00011011
59
$3B
00111011
28
$1C
00011100
60
$3C
00111100
29
$1D
00011101
61
$3D
00111101
30
$1E
00011110
62
$3E
00111110
31
$1F
0001 1111
63
$3F
001 1 1 1 1 1
391
Table A-4— cont. Decimal/Hexadecimal/Binary Table
for Decimal Values Through 255
DEC
HEX
BIN
DEC
HEX
BIN
64
$40
01000000
96
$60
01100000
65
$41
01000001
97
$61
01100001
66
$42
01000010
98
S62
01100010
67
$43
01000011
99
$63
01100011
68
$44
01000100
100
$64
01100100
69
$45
01000101
101
$65
01100101
70
$46
01000110
102
$66
01100110
71
$47
01000111
103
$67
01100111
72
$48
01001000
104
$68
01101000
73
$49
01001001
105
$69
01101001
74
$4A
01001010
106
$6A
01101010
75
$48
01001011
107
$68
01101011
76
$4C
01001100
108
$6C
01101100
77
$4D
01001101
109
$6D
01101101
78
$4E
01001110
110
$6E
01101110
79
$4F
01001111
111
$6F
01101111
80
$50
01010000
112
$70
01110000
81
$51
01010001
113
$71
01110001
82
$52
01010010
114
$72
01110010
83
$53
01010011
115
$73
01110011
84
$54
01010100
116
$74
01110100
85
$55
01010101
117
$75
01110101
86
$56
01010110
118
$76
01110110
87
$57
01010111
119
$77
01110111
88
$58
01011000
120
$78
01111000
89
$59
01 01 1 001
121
$79
01111001
90
$5A
01011010
122
$7A
01111010
91
$58
01 01 1 01 1
123
$78
01111011
92
$5C
01011100
124
$7C
01111100
93
$5D
01011101
125
$7D
01111101
94
$5E
01011110
126
$7E
01111110
95
$5F
01011111
127
$7F
01111111
392
Table A-4— cont. Decimal/Hexadecimal/Binary Table
for Decimal Values Through 255
DEC
HEX
BIN
DEC
HEX
BIN
128
$80
10000000
160
$A0
10100000
129
$81
1 0000001
161
$A1
10100001
130
$82
10000010
162
$A2
10100010
131
$83
10000011
163
$A3
10100011
132
$84
10000100
164
$A4
10100100
133
$85
10000101
165
$A5
10100101
134
S86
10000110
166
$A6
10100110
135
$87
10000111
167
$A7
10100111
136
S88
10001000
168
$A8
10101000
137
$89
10001001
169
$A9
10101001
138
$8A
10001010
170
$AA
10101010
139
$8B
10001011
171
$AB
10101011
140
$8C
10001100
172
$AC
10101100
141
$8D
10001101
173
$AD
10101101
142
$8E
10001110
174
$AE
10101110
143
$8F
10001111
175
$AF
10101111
144
$90
10010000
176
$B0
10110000
145
$91
10010001
177
$B1
10110001
146
$92
10010010
178
$B2
10110010
147
$93
10010011
179
$B3
10110011
148
$94
10010100
180
$B4
10110100
149
$95
10010101
181
$B5
10110101
150
$96
10010110
182
$B6
10110110
151
$97
10010111
183
$B7
10110111
152
$98
10011000
184
$88
10111000
153
$99
10011001
185
$B9
10111001
154
$9A
10011010
186
$BA
10111010
155
$9B
10011011
187
$BB
10111011
156
$9C
10011100
188
SBC
10111100
157
$9D
10011101
189
SBD
10111101
158
$9E
10011110
190
$BE
10111110
159
$9F
10011111
191
$BF
10111111
393
Table A-4— cont. Decimal/Hexadecimal/Binary Table
for Decimal Values Through 255
DEC
HEX
BIN
DEC
HEX
BIN
192
$C0
11000000
224
$E0
11100000
193
$C1
11000001
225
$E1
11100001
194
$C2
11000010
226
$E2
11100010
195
$C3
11000011
227
$E3
11100011
196
$C4
11000100
228
$E4
11100100
197
$C5
11000101
229
$E5
11100101
198
$C6
11000110
230
$E6
11100110
199
SC7
11000111
231
$E7
11100111
200
$C8
11001000
232
SE8
11101000
201
$C9
11001001
233
$E9
11101001
202
$CA
11001010
234
$EA
11101010
203
$CB
11001011
235
$EB
11101011
204
$CC
11001100
236
$EC
11101100
205
$CD
11001101
237
$ED
11101101
206
$CE
11001110
238
$EE
11101110
207
$CF
11001111
239
$EF
11101111
208
$D0
11010000
240
$F0
11110000
209
$D1
11010001
241
SF1
11110001
210
$D2
11010010
242
$F2
11110010
211
$D3
11010011
243
SF3
11110011
212
$D4
11010100
244
$F4
11110100
213
$D5
11010101
245
$F5
11110101
214
$D6
11010110
246
$F6
11110110
215
$D7
11010111
247
$F7
11110111
216
$D8
11011000
248
$F8
11111000
217
$D9
11011001
249
$F9
11111001
218
$DA
11011010
250
$FA
11111010
219
$DB
11011011
251
$FB
11111011
220
$DC
11011100
252
$FC
11111100
221
$DD
11011101
253
$FD
11111101
222
$DE
11011110
254
$FE
11111110
223
$DF
11011111
255
SFF
11111111
394
Appendix B
ATARI BASIC Reserved Words
and Tokens
Chart B-1 lists the reserved words for ATARI BASIC. These
must not be used as variable names.
Table B-1 shows the ATARI BASIC commands, opera-
tors, and functions that are tokenized in RAM as they are
entered from the keyboard. BASIC programs can be saved
on cassette tape or disk in this abbreviated format, or they
can be saved as longer ATASCII character codes. See
Chapter 7 for a discussion of the tokenizing procedure.
395
Chart B-1. ATARI BASIC Reserved Words
ATARI
BASIC Reserved Words
ABS
LEN
SGN
ADR
LET
SIN
AND
LIST
SOUND
ASC
LOAD
SQR
ATN
LOCATE
STATUS
BYE
LOG
STEP
CLOAD
LPRINT
STICK
CHR$
NEW
STRIG
CLOG
NEXT
STOP
CLOSE
NOT
STR$
CLR
NOTE
THEN
COLOR
ON
TO
COM
OPEN
TRAP
CONT
OR
USR
COS
PADDLE
VAL
CSAVE
PEEK
XIO
DATA
PLOT
DEC
POINT
DIM
POKE
DOS
POP
DRAWTO
POSITION
END
PRINT
ENTER
PTRIG
EXP
PUT
FOR
RAD
PRE
READ
GET
REM
GOSUB
RESTORE
GOTO
RETURN
GRAPHICS
RND
IF
RUN
INPUT
SAVE
INT
SETCOLOR
396
Table B-1 . ATARI BASIC Command Keywords
and Their Decimal/Hexadecimal Tokens
Command Tokens
Command Tokens
Dec
Hex
Keyword
Dec
Hex
Keyword
$00
REM
28
$1C
POINT
1
$01
DATA
29
$1D
XIO
2
$02
INPUT
30
$1E
ON
3
S03
COLOR
31
$1F
POKE
4
$04
LIST
32
$20
PRINT
5
$05
ENTER
33
$21
RAD
6
$06
LET
34
$22
READ
7
$07
IF
35
$23
RESTORE
8
$08
FOR
36
$24
RETURN
9
$09
NEXT
37
$25
RUN
10
$0A
GOTO
38
$26
STOP
11
$0B
GOTO
39
$27
POP
12
$0C
GOSUB
40
$28
7
13
$0D
TRAP
41
$29
GET
14
$0E
BYE
42
$2A
PUT
15
$0F
CONT
43
$2B
GRAPHICS
16
$10
COM
44
$2C
PLOT
17
$11
CLOSE
45
$2D
POSITION
18
$12
CLR
46
$2E
DOS
19
$13
DEG
47
S2F
DRAWTO
20
$14
DIM
48
$30
SETCOLOR
21
$15
END
49
$31
LOCATE
22
$16
NEW
50
$32
SOUND
23
$17
OPEN
51
$33
LPRINT
24
$18
LOAD
52
$34
CSAVE
25
$19
SAVE
53
$35
CLOAD
26
$1A
STATUS
54
$36
implied LET
27
$18
NOTE
55
$37
ERROR - (syntax)
397
Table B-1— cont. ATARI BASIC Operator Keywords
and Their Decimal/Hexadecimal Tokens
Operator Tokens
Operator Tokens
Dec
Hex
Keyword
Dec
Hex
Keyword
14
$E
num constant
37
$25
+
15
$F
string constant
38
$26
-
16
$10
not used
39
$27
/
17
$11
not used
40
$28
NOT
18
$12
,
41
$29
OR
19
$13
$
42
$2A
AND
20
$14
: (end of statement)
43
$2B
(
21
$15
j
44
$2C
)
22
$16
end of line
45
$2D
= (num assign)
23
$17
GOTO
46
$2E
= (str assign)
24
$18
GOSUB
47
$2F
< = (string)
25
$19
TO
48
$30
<>
26
$1A
STEP
49
$31
> =
27
$1B
THEN
50
$32
<
28
$1C
#
51
$33
>
29
$1D
< = (numeric)
52
$34
^
30
$1E
<>
53
$35
+ (unary)
31
$1F
> =
54
$36
-
32
$20
<
55
$37
( (as in a string)
33
$21
>
56
$38
( (array)
34
$22
=
57
$39
( (array)
35
$23
58
$3A
( (function)
36
S24
*
59
$3B
( (dimension)
60
$3C
, (as in an array)
398
Table B-1— cont. ATARI BASIC Function Keywords
and Their Decimal/Hexadecimal Tokens
Function Tokens
Function Tokens |
Dec
Hex
Keyword
Dec
Hex
Keyword
61
$3D
STR$
73
$49
FRE
62
$3E
CHR$
74
$4A
EXP
63
$3F
USR
75
$48
LOG
64
$40
ASC
76
$4C
CLOG
65
$41
VAL
77
$4D
SQR
66
$42
LEN
78
$4E
SGN
67
$43
ADR
79
$4F
ABS
68
$44
ATN
80
$50
INT
69
$45
COS
81
$51
PADDL
70
$46
PEEK
82
$52
STICK
71
$47
SIN
83
$53
PTRIG
72
$48
RND
84
$54
STRIG
399
Appendix C
ATARI Character Codes
Table C-1 lists the decimal and hexadecimal codes for the
ATARI ATASCii characters and control functions. The
table also indicates the conventional ASCII characters and
control operations and the ATARI keystrokes that gener-
ate the ATASCII codes.
Keystroke designations that are separated by a hyphen
indicate simultaneous key depressions. For example,
CTRL-2 means strike the 2 key while holding down the
CTRL key.
Keystroke designations that are separated by a slash
indicate a sequence of keystrokes. For example, ESC/
BACK S means strike the ESC key followed by the BACK S
key.
Table C-2 portrays the ATARI system's internal character
set. It shows the decimal or hexadecimal value, the ATARI
character and the starting and ending addresses of the
ROM location for that character. Inverse characters are
generated by setting the most-significant bit of the code
to 1, or adding 128 to the decimal code.
401
Table C-1 The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
$00
♦I
NUL
CTRL-,
1
$01
1-
SOH
CTRL-A
2
$02
II
STX
CTRL-B
3
$03
J
ETX
CTRL-C
4
$04
A
EOT
CTRL-D
5
$05
n
ENQ
CTRL-E
6
$06
\y
ACK
CTRL-F
7
$07
\
BEL
CTRL-G
8
$08
\A
BS
CTRL-H
9
$09
■
HT
CTRL-I
10
$0A
k
LF
CTRL-J
11
$0B
■
VT
CTRL-K
12
$0C
■
FF
CTRL-L
13
SOD
^
CR
CTRL-M
14
$0E
.«
SO
CTRL-N
15
$0F
i 1
!■ 1
SI
CTRL-0
16
$10
1+
OLE
CTRL-P
17
$11
[ri
DC1
CTRL-O
402
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
Character
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$12
$13
$14
$15
$16
$17
$18
$19
$1A
$1B
$1C
$1D
$1E
$1F
$20
$21
$22
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US
(space)
!
CTRL-R
CTRL-S
CTRL-T
CTRL-U
CTRL-V
CTRL-W
CTRL-X
CTRL-Y
CTRL-Z
ESC/ESC
ESC/CTRL-
ESC/CTRL-=
ESC/CTRL-+
ESC/CTRL-*
Space Bar
SHIFT- 1
SHIFT-2
+
•
^
1
T
A
1
L
«:
t
«
4-
r
i
'■' •
403
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
35
$23
.. ■
#
SHIFTS
36
$24
i-
$
SHIFT-4
37
$25
■•' K
%
SHIFT-5
38
$26
••••••
&
SHIFT-6
39
$27
:
•
SHIFT-7
40
$28
r
(
SHIFTS
41
$29
*: ;
)
SHIFT-0
42
$2A
: '"• 1
*
»
43
$2B
>i
+
+
44
$2C
■ t '
.
,
45
$2D
....
-
-
46
$2E
' • i
47
$2F
'••■" i
/
/
48
$30
49
$31
: •: '
1
1
50
$32
2
2
51
$33
-:
•«.•
3
3
404
Table C-1— cont. The ATARI ATASCII Character Set
Code
Dec
Hex
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$34
$35
$36
$37
$38
S39
$3A
$3B
$3C
$3D
$3E
$3F
$40
$41
$42
$43
$44
? i
!<?
n
<
>
A
B
C
D
4
5
6
7
8
9
SHIFT-;
<
>
SHIFT-/
SHIFT-8
A
B
C
D
405
Table C-1 — cont. The ATARI ATASCII Character Set
Code
ATASCII
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
Character
69
$45
i t.« '
E
E
70
71
$46
$47
__
r
F
G
F
G
b
72
$48
1 LJ i
H
H
73
$49
' — ~ 1
1
1
74
75
$4A
$48
J
J
K
J
K
u
it
76
$4C
*** !
L
L
77
$40
M
M
78
$4E
: -.
1 \,
N
N
79
$4F
iCy
80
$50
|P|
P
P
81
$51
Q
Q
Q
82
83
$52
$53
R
R
S
R
S
84
$54
T
T
T
85
$55
nj
U
U
406
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
Character
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
$56
$57
$58
S59
$5A
$58
$5C
$5D
$5E
$5F
S60
$61
$62
$63
$64
$65
$66
V
W
X
Y
Z
[
\
]
N
a
b
c
d
e
f
V
W
X
Y
Z
SHIFT-
SHIFT-,
SHIFT- +
SHIFT-*
SHIFT--
CTRL-.
LOWRA
LOWRB
LOWRC
LOWRD
LOWRE
LOWRF
u
N
*•, ^t*
Y
7'
-
■••..
"
•••■••.
♦
3
b
c
d
9
f
407
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
Character
103
$67
5
9
LOWRG
104
$68
r .
L!l
h
LOWRH
105
$69
- —
1
i
LOWRI
106
$6A
i
J
LOWRJ
107
108
109
110
111
112
$6B
$6C
$60
$6E
$6F
$70
k
k
1
m
n
P
LOWRK
LOWRL
LOWRM
LOWRN
LOWRO
LOWRP
1
a.
n
n
o
p
113
114
115
116
117
$71
$72
$73
$74
$75
=1.
q
r
s
t
u
LOWRQ
LOWRR
LOWRS
LOWRT
LOWRU
5
t
u
118
119
$76
$77
V
V
w
LOWR V
LOWR W
i«
408
Table C-1 — cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
120
$78
■ •...• ;
X
LOWRX
121
$79
3
y
LOWR Y
122
$7A
\ -•
z
LOWRZ
123
$7B
!*'
1
CTRL-;
124
$7C
1 1
1 '
1
SHIFT- =
125
$7D
m.
1
ESC/CTRL-<
126
$7E
4
~
ESC/BACK S
127
$7F
>
DEL
ESC/TAB
128
$80
□
NUL
CTRL-,
129
$81
D
SOH
CTRL- A
130
$82
n
STX
CTRL-B
131
$83
a
ETX
CTRL-C
132
$84
u
EOT
CTRL-D
133
$85
a
ENQ
CTRL-E
134
$86
a
ACK
CTRL-F
135
$87
ia
BEL
CTRL-G
136
$88
n
BS
CTRL-H
409
Table
C-1-cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
137
$89
B
HT
CTRL-I
138
$8A
a
LF
CTRL-J
139
$8B
B
VT
CTRL-K
140
$8C
a
FF
CTRL-L
141
$8D
H
CR
CTRL-M
142
$8E
B
SO
CTRL-N
143
$8F
9
SI
CTRL-0
144
$90
□
DLE
CTRL-P
145
$91
D
DC1
CTRL-Q
146
$92
B
DC2
CTRL-R
147
$93
□
DC3
CTRL-S
148
$94
a
DC4
CTRL-T
149
$95
H
NAK
CTRL-U
150
$96
n
SYN
CTRL-V
151
$97
a
ETB
CTRL-W
152
$98
a
CAN
CTRL-X
153
$99
a
EM
CTRL-Y
410
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
KeYStroke(s)
Dec
Hex
154
$9A
D
SUB
CTRL-Z
155
$9B
E3
ESC
RETURN
156
$9C
□
FS
ESC/SHIFT-BACK S
157
$9D
□
GS
ESC/SHIFT->
158
$9E
Q
RS
ESC/CTRL-TAB
159
$9F
□
US
ESC/SHIFT-TAB
160
SAO
■
(space)
Space Bar
161
$A1
■
!
SHIFT- 1
162
$A2
■
"
SHIFT-2
163
$A3
g
#
SHIFT-a
164
$A4
H
$
SHIFT-4
165
$A5
■
%
SHIFT-5
166
$A6
B
&
SHIFT-6
167
$A7
■
SHIFT-7
168
$A8
■
(
SHIFT-9
169
$A9
■
)
SHIFT-0
170
$AA
H
*
*
411
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
171
$AB
H
+
+
172
SAC
B
,
,
173
SAD
B
-
174
SAE
B
175
SAF
B
/
/
176
SBO
B
177
SB1
B
1
1
178
SB2
B
2
2
179
$B3
B
3
3
180
SB4
m
4
4
181
SB5
Q
5
5
182
$86
B
6
6
183
$B7
19
7
7
184
$B8
B
8
8
185
SB9
B
9
9
186
SBA
B
SHIFT-;
187
SBB
B
■
412
Table C-1— cont. The ATARI ATASCII Character Set
Code
Dec
Hex
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
188
SBC
189
$BD
190
SBE
191
$BF
192
SCO
193
$C1
194
$C2
195
$C3
196
$C4
197
$C5
198
$C6
199
$C7
200
$C8
201
$C9
202
$CA
203
SCB
204
$CC
<
>
?
@
A
B
C
D
E
. F
G
H
I
J
K
L
>
SHIFT-/
SHIFT-8
A
B
C
D
E
F
G
H
I
J
K
L
413
Table C-1— cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
205
$CD
m
M
M
206
$CE
m
N
N
207
$CF
H
208
.$D0
H
P
P
209
$D1
H
Q
Q
210
$D2
B
R
R
211
$D3
B
S
S
212
$D4
B
T
T
213
$D5
B
U
U
214
$D6
B
V
V
215
$D7
l^g
w
w
216
$D8
B
X
X
217
$D9
B
Y
Y
218
$DA
B
z
z
219
$DB
B
[
SHIFT-,
220
$DC
B
\
SHIFT- +
221
$DD
B
]
SHIFT-.
414
Table C-1 — cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
222
$DE
■
-
SHIFT-*
223
$DF
■
—
SHIFT-
224
$E0
□
V
CTRL-.
225
$E1
m
a
LOWRA
226
$E2
B
b
LOWRB
227
$E3
m
c
LOWRC
228
SE4
m
d
LOWRD
229
$E5
m
e
LOWRE
230
$E6
B
f
LOWR F
231
$E7
m
g
LOWRG
232
$E8
B
h
LOWRH
233
$E9
B
i
LOWRI
234
SEA
B
J
LOWR J
235
$EB
B
k
LOWRK
236
SEC
B
1
LOWRL
237
SED
B
m
LOWR M
238
SEE
B
n
LOWRN
415
Table C-1 —
cont. The ATARI ATASCII Character Set
Code
ATASCII
Character
ASCII
Character
or Control
Keystroke(s)
Dec
Hex
239
$EF
H
LOWRO
240
$F0
H
P
LOWR P
241
$F1
B
q
LOWRQ
242
$F2
H
r
LOWRR
243
$F3
B
s
LOWRS
244
$F4
B
t
LOWRT
245
$F5
B
u
LOWRU
246
$F6
B
V
LOWRV
247
$F7
g
w
LOWR W
248
$F8
B
X
LOWRX
249
$F9
B
y
LOWR Y
250
$FA
H
z
LOWRZ
251
$FB
□
1
CTRL-;
252
$FC
B
1
SHIFT-=
253
$FD
□
I
ESC/CTRL-2
254
$FE
□
~
ESC/CTRL-BACK S
255
$FF
□
DEL
ESC/CTRL->
416
Table C-2. The ATARI System's Internal Character Set
Code
Character
ROM Map Addresses |
Decimal
Hexadecimal |
Dec
Hex
Start
End
Start
End
$00
1
1
57344
57351
$E000
$E007
1
$01
1 .
i i
1 .
1 — I i
57352
57359
$E008
$EOOF
2
$02
1"
57360
57367
$E010
$E017
3
S03
#
57368
57375
$E018
$E01F
4
5
S04
$05
i
57376
57384
57383
57391
SE020
$E028
$E027
$E02F
.■■„
6
7
8
$06
$07
$08
•^ *•
57392
57400
57408
57399
57407
57415
$E030
$E038
$E040
$E037
$E03F
$E047
:
(
9
10
11
$09
$0A
$0B
'i
57416
57424
57432
57423
57431
57439
$E048
$E050
$E058
$E04F
$E057
$E05F
. _.
•t-
12
$0C
f
57440
57447
$E060
$E067
13
$0D
._
57448
57455
$E068
$E06F
14
$0E
♦
57456
57463
$E070
$E077
15
$0F
••■'
57464
57471
$E078
$E07F
417
Table C-2— cont. The ATARI System's
Internal Character Set
Code
Dec
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Hex
$10
$11
$12
$13
$14
$15
$16
$17
S18
$19
$1A
$1B
$1C
$1D
$1E
$1F
Character
I - i
ROM Map Addresses
Decimal
Start
57472
57480
57488
57496
57504
57512
57520
57528
57536
57544
57552
57560
57568
57576
57584
57592
End
57479
57487
57495
57503
57511
57519
57527
57535
57543
57551
57559
57567
57575
57583
57591
57599
Hexadecimal
Start
$E080
$E088
$E090
$E098
$E0A0
$E0A8
$E0B0
$E0B8
$EOCO
SE0C8
$EODO
$E0D8
$EOEO
$E0E8
$EOFO
$E0F8
End
$E087
$E08F
$E097
$E09F
$E0A7
$E0AF
$E0B7
$E0BF
$E0C7
$E0CF
$E0D7
$EODF
$E0E7
$EOEF
$E0F7
$EOFF
418
Table C-2— cont. The ATARI System's
Internal Character Set
Code
Dec
Hex
Character
ROM Map Addresses
Decimal
Start
End
Hexadecimal
Start
End
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$20
$21
$22
$23
$24
$25
$26
$27
$28
$29
$2A
$2B
$2C
$2D
$2E
$2F
n
M
57600
57608
57616
57624
57632
57640
57648
57656
57664
57672
57680
57688
57696
57704
57712
57720
57607
57615
57623
57631
57639
57647
57655
57663
57671
57679
57687
57695
57703
57711
57719
57727
$E100
SE108
$E110
$E118
SE120
$E128
$E130
$E138
$E140
$E148
$E150
$E158
$E160
$E168
$E170
$E178
$E107
$E10F
$E117
$E11F
$E127
$E12F
$E137
$E13F
$E147
$E14F
$E157
$E15F
$E167
$E16F
$E177
$E17F
419
Table C-2— cont. The ATARI System's
Internal Character Set
Code
ROM Map Addresses |
Character
Decimal
Hexadecimal
Dec
Hex
Start
End
Start
End
48
$30
! „ ;
57728
57735
$E180
$E187
49
$31
iQi
57736
57743
$E188
$E18F
50
$32
R^
57744
57751
$E190
$E197
51
$33
57752
57759
$E198
$E19F
52
$34
it:
57760
57767
$E1A0
$E1A7
53
$35
Li;
57768
57775
$E1A8
$E1AF
54
55
56
57
58
59
$36
$37
$38
$39
$3A
$3B
U
57776
57784
57792
57800
57808
57816
57783
57791
57799
57807
57815
57823
$E1B0
$E1B8
$E1C0
$E1C8
$E1D0
$E1D8
$E1B7
$E1BF
$E1C7
$E1CF
$E1D7
$E1DF
N
.••••..
Y
Z
■-
60
61
62
63
$3C
$3D
$3E
$3F
57824
57832
57840
57848
57831
57839
57847
57855
$E1E0
$E1E8
$E1F0
$E1F8
$E1E7
$E1EF
$E1F7
$E1FF
]
.••■••.
420
Table C-2— cont. The ATARI System's
internal Character Set
Code
Character
ROM Map Addresses
Decimal
Hexadecimal |
Dec
Hex
Start
End
Start
End
64
$40
□
57856
57863
$E200
$E207
65
$41
D
57864
57871
$E208
$E20F
66
$42
B
57872
57879
$E210
$E217
67
S43
a
57880
57887
$E218
$E21F
68
$44
a
57888
57895
$E220
$E227
69
$45
a
57896
57903
$E228
$E22F
70
$46
Q
57904
57911
$E230
$E237
71
$47
□
57912
57919
$E238
$E23F
72
$48
B
57920
57927
$E240
$E247
73
$49
B
57928
57935
$E248
$E24F
74
$4A
n
57936
57943
$E250
$E257
75
$4B
B
57944
57951
$E258
$E25F
76
$4C
a
57952
57959
$E260
$E267
77
S4D
H
57960
57967
$E268
$E26F
78
$4E
H
57968
57975
$E270
$E277
79
$4F
9
57976
57983
$E278
$E27F
421
Table C-2— cont. The ATARI System's
Internal Character Set
Code
Character
ROM Map Addresses |
Decimal
Hexadecimal
Dec
Hex
Start
End
Start
End
80
$50
□
57984
57991
$E280
$E287
81
$51
D
57992
57999
$E288
$E28F
82
S52
H
58000
58007
$E290
$E297
83
$53
u
58008
58015
$E298
$E29F
84
$54
n
58016
58023
$E2A0
$E2A7
85
$55
H
58024
58031
$E2A8
$E2AF
86
$56
n
58032
58039
$E2B0
$E2B7
87
$57
□
58040
58047
$E2B8
$E2BF
88
$58
E3
58048
58055
$E2C0
$E2C7
89
$59
a
58056
58063
$E2C8
$E2CF
90
$5A
D
58064
58071
$E2D0
$E2D7
91
$58
B
58072
58079
$E2D8
$E2DF
92
$5C
□
58080
58087
$E2E0
$E2E7
93
$5D
□
58088
58095
$E2E8
$E2EF
94
$5E
Q
58096
58103
$E2F0
$E2F7
95
$5F
□
58104
58111
$E2F8
$E2FF
422
Table C-2— cont. The ATARI System's
Internal Character Set
Code
ROM Map Addresses
Character
Decimal
Hexadecimal |
Dec
Hex
Start
End
Start
End
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
$60
$61
$62
$63
$64
$65
$66
$67
$68
$69
$6A
$6B
$6C
$6D
$6E
$6F
□
3
58112
58120
58128
58136
58144
58152
58160
58168
58176
58184
58192
58200
58208
58216
58224
58232
58119
58127
58135
58143
58151
58159
58167
58175
58183
58191
58199
58207
58215
58223
58231
58239
$E300
$E308
$E310
$E318
$E320
$E328
$E330
$E338
$E340
$E348
$E350
$E358
$E360
$6368
$E370
$E378
$E307
$E30F
$E317
$E31F
$E327
$E32F
$E337
$E33F
$E347
$E34F
$E357
$E35F
$E367
$E36F
$E377
$E37F
b
C
d
P
T
^
n
i
^•
1
fl
n
o
■■^^
423
Table C-2— cont. The ATARI System's
Internal Character Set
Code
Character
ROM Map Addresses |
Decimal
Hexadecimal |
Dec
Hex
Start
End
Start
End
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
$70
$71
$72
$73
$74
S75
$76
$77
$78
$79
$7A
$7B
$7C
$7D
$7E
S7F
58240
58248
58256
58264
58272
58280
58288
58296
58304
58312
58320
58328
58336
58344
58352
59360
58247
58255
58263
58271
58279
58287
58295
58303
58311
58319
58327
58335
58343
58351
58359
58367
$E380
$E388
$E390
$E398
$E3A0
$E3A8
$E3B0
$E3B0
$E3C0
$E3C8
$E3D0
$E3D8
$E3E0
$E3E8
$E3F0
SE3F8
$E387
$E38F
$E397
$E39F
$E3A7
$E3AF
$E3B7
$E3BF
$E3C7
$E3CF
$E3D7
$E3DF
$E3E7
$E3EF
SE3F7
$E3FF
r
L
P
q
r
r
5
t
u
V
z
□
««
4
:
>■
424
Appendix D
ATARI Keyboard Codes
Every keystroke and appropriate combination of key-
strokes produces a character code that represents that
keyboard action. The tables shown here list those key-
strokes and codes that are subsequently generated within
the ATARI system.
Tables D-1 through D-3 list the information by showing
the keystroke and corresponding decimal and hexade-
cimal codes. Table D-4 lists the same information, but it is
organized according to the numerical sequence of the
codes.
425
Table D-1 . Keystrokes and Corresponding Key Codes
(Single-Key Operations)
Key
Code
Key
Code
Dec
Hex
Dec
Hex
Space Bar
32
S20
9
57
$39
!
33
S21
58
$3A
"
34
$22
;
59
$3B
#
35
$23
<
60
$3C
$
36
$24
=
61
$3D
%
37
$25
>
62
$3E
&
38
$26
?
63
$3F
'
39
$27
@
64
$40
(
40
$28
A
65
$41
)
41
$29
B
66
$42
»
42
$2A
C
67
$43
+
43
$2B
D
68
$44
.
44
$2C
E
69
$45
—
45
$2D
F
70
$46
46
$2E
G
71
$47
/
47
$2F
H
72
$48
48
$30
1
73
$49
1
49
$31
J
74
$4A
2
50
$32
K
75
$4B
3
51
$33
L
76
$4C
4
52
$34
M
77
$40
5
53
$35
N
78
$4E
6
54
$36
79
$4F
7
55
$37
P
80
$50
8
56
$38
Q
81
$51
426
Table D-1 — cont. Keystrokes and Corresponding
Key Codes (Single-Key Operations)
Key
Code
Key
Code 1
Dec
Hex
Dec
Hex
R
82
$52
1
108
$6C
S
83
$53
m
109
$6D
T
84
$54
n
110
$6E
U
85
$55
o
111
$6F
V
86
$56
P
112
$70
w
87
$57
q
113
$71
X
88
$58
r
114
$72
Y
89
$59
s
115
$73
z
90
$5A
t
116
$74
[
91
$5B
u
117
$75
/
92
$5C
V
118
$76
1
93
$5D
w
119
$77
-
94
$5E
X
120
$78
—
95
$5F
y
121
$79
a
97
$61
z
122
$7A
b
98
$62
1
124
$7C
c
99
S63
ESC
127
$1B
d
100
$64
CLEAR
125
S7D
e
101
$65
BACKS
126
$7E
f
102
$66
TAB
127
$7F
g
103
$67
RETURN
155
$9B
h
104
$68
DELETE
156
$9C
i
105
$69
INSERT
157
$9D
J
106
$6A
TAB
158
$9E
k
107
$6B
SET
159
$9F
427
Table D-2. Keystrokes and Corresponding Key Codes
(CTRL-Key Operations)
Key
Code
Key
Code 1
Dec
Hex
Dec
Hex
CTRL-,
$00
CTRL-S
19
$13
CTRL-A
1
$01
CTRL-T
20
$14
CTRL-B
2
$02
CTRL-U
21
$15
CTRL-C
3
S03
CTRL-V
22
$16
CTRL-D
4
$04
CTRL-W
23
$17
CTRL-E
5
$05
CTRL-X
24
$18
CTRL-F
6
$06
CTRL-Y
25
$19
CTRL-G
7
$07
CTRL-Z
26
$1A
CTRL-H
8
$08
CTRL-
28
$1C
CTRL-1
9
$09
CTRL-
29
$1D
CTRL-J
10
$0A
CTRL-
30
$1E
CTRL-K
11
$08
CTRL-
31
$1F
CTRL-L
12
$0C
CTRL-.
96
$60
CTRL-M
13
$00
CTRL-;
123
$78
CTRL-N
14
$0E
CTRL-2
253
$FD
CTRL-0
15
$0F
CTRL-3
155
$98
CTRL-P
16
$10
CTRL-DELETE
254
$FE
CTRL-Q
17
$11
CTRL-INSERT
255
$FF
CTRL-R
18
$12
NOTE: CTHL-key operations that are not indicated here will generate
the same codes as their non-CTRL counterparts.
428
Table D-3. Keystrokes and Corresponding Key Codes
(Inverse- Key Operations)
Key
Code
Key
Code 1
Dec
Hex
Dec
Hex
<inv.> CTRL-,
128
$80
<inv.> 1
177
$B1
<inv.> CTRL-A
129
$81
<inv.> 2
178
$B2
<inv.> CTRL-B
130
$82
<inv.> 3
179
$B3
<inv.> CTRL-C
131
$83
<inv.> 4
180
$B4
<inv.> CTRL-D
132
$84
<inv.> 5
181
$B5
<inv.> CTRL-E
133
$85
<inv.> 6
182
$B6
<inv.> CTRL-F
134
$86
<inv.> 7
183
$B7
<inv.>CTRL-G
135
$87
<inv.> 8
184
$B8
<inv.> CTRL-H
136
$88
<inv.> 9
185
$89
<inv.> CTRL-I
137
$89
<inv.> :
186
$BA
<inv.> CTRL-J
138
$8A
<inv.> ;
187
$BB
<inv.> CTRL-K
139
$8B
<inv.> <
188
$BC
<inv.> CTRL-L
140
$8C
<inv.> =
189
$BD
<inv.> CTRL-M
141
$8D
<inv.> >
190
$BE
<inv.> CTRL-N
142
$8E
<inv.> ?
191
$BF
<inv.> CTRL-0
143
$8F
<inv.> @
192
$C0
<inv.>CTRL-P
144
$90
<inv.> A
193
$C1
<inv.> CTRL-Q
145
$91
<inv.> B
194
$C2
<inv.> CTRL-R
146
$92
<inv.> C
195
$C3
<inv.> CTRL-S
147
$93
<inv.> D
196
$C4
<inv.> CTRL-T
148
$94
<inv.> E
197
$C5
<inv.> CTRL-U
149
$95
<inv.> F
198
$C6
<inv.> CTRL-V
150
$96
<inv.> G
199
$C7
<inv.> CTRL-W
151
$97
<inv.> H
200
$C8
<inv.> CTRL-X
152
$98
<inv.> 1
201
$C9
<inv.> CTRL-Y
153
$99
<inv.> J
202
$CA
<inv.> CTRL-Z
154
$9A
<inv.> K
203
$CB
<inv.> Spc Bar
160
$A0
<inv.> L
204
$CC
<inv.> !
161
$A1
<inv.> M
205
$CD
<inv.> "
162
$A2
<inv.> N
206
$CE
<inv.> #
163
$A3
<inv.>
207
$CF
<inv.> S
164
$A4
<inv.> P
208
$00
<inv.> %
165
$A5
<inv.> Q
209
$01
<inv.> &
166
$A6
<inv.> R
210
$D2
<inv.> '
167
$A7
<inv.> S
211
$D3
<inv.>(
168
$A8
<inv.>T
212
$D4
<inv.> )
169
$A9
<inv.> U
213
$D5
<inv.> *
170
$AA
<inv.> V
214
$D6
<inv.> +
171
$AB
<inv.>W
215
$D7
<inv.> ,
172
$AC
<inv.> X
216
$08
<inv.> -
173
$AD
<inv.>Y
217
$D9
<inv.> .
174
$AE
<inv.>Z
218
$DA
<inv.> /
175
$AF
<inv.> [
219
$DB
<inv.>
176
$B0
<inv.> \
220
SDC
429
Table D-3— cont. Keystrokes and Corresponding
Key Codes (Inverse-Key Operations)
Key
Code
Key
Code
Dec
Hex
Dec
Hex
<inv.>]
221
$DD
<inv.> n
238
SEE
<inv.> -
222
$DE
<inv.>o
239
SEF
<inv.> —
223
$DF
<inv.>p
240
$F0
<inv.> a
225
$E1
<inv.>q
241
SF1
<inv.> b
226
$E2
<inv.> r
242
$F2
<inv.> c
227
$E3
<inv.>s
243
SF3
<inv.>d
228
$E4
<inv.>t
244
SF4
<inv.> e
229
$E5
<inv.> u
245
$F5
<inv.>f
230
$E6
<inv.> V
246
$F6
<inv.> g
231
$E7
<inv.> w
247
SF7
<inv.> h
232
$E8
<inv.> X
248
SF8
<inv.> i
233
SE9
<inv.>y
249
SF9
<inv.> j
234
SEA
<inv.>z
250
SFA
<inv.> k
235
$EB
<inv.>|
252
SFC
<inv.> 1
236
SEC
<inv.>CTRL-.
224
SEO
<inv.> m
237
SED
<inv.> CTRL-;
251
SFB
430
Table D-4. Keystrokes and Corresponding Key Codes
Arranged With Key Codes in Numerical Order
Code
Key
Code
Key
Dec
Hex
Dec
Hex
$00
CTRL-,
43
$2B
-1-
1
$01
CTRL- A
44
$2C
2
S02
CTRL-B
45
$2D
-
3
$03
CTRL-C
46
$2E
4
$04
CTRL-D
47
$2F
/
5
$05
CTRL-E
48
$30
6
$06
CTRL-F
49
$31
1
7
$07
CTRL-G
50
$32
2
8
$08
CTRL-H
51
$33
3
9
$09
CTRL-I
52
$34
4
10
$0A
CTRL-J
53
$35
5
11
$0B
CTRL-K
54
$36
6
12
$0C
CTRL-L
55
$37
7
13
$0D
CTRL-M
56
$38
8
14
$0E
CTRL-N
57
$39
9
15
$0F
CTRL-0
58
$3A
16
$10
CTRL-P
59
$38
17
$11
CTRL-Q
60
$3C
<
18
$12
CTRL-R
61
$30
=
19
$13
CTRL-S
62
$3E
>
20
$14
CTRL-T
63
$3F
?
21
$15
CTRL-U
64
$40
@
22
$16
CTRL-V
65
$41
A
23
$17
CTRL-W
66
$42
B
24
$18
CTRL-X
67
$43
C
25
$19
CTRL-Y
68
$44
D
26
$1A
CTRL-Z
69
$45
E
27
$1B
ESC
70
$46
F
28
$1C
CTRL-
71
$47
G
29
SID
CTRL-
72
$48
H
30
$1E
CTRL-
73
$49
1
31
$1F
CTRL-
74
$4A
J
32
$20
Space Bar
75
$4B
K
33
$21
!
76
$4C
L
34
S22
"
77
$4D
M
35
$23
#
78
$4E
N
36
$24
$
79
$4F
37
$25
%
80
$50
P
38
$26
&
81
$51
Q
39
$27
'
82
$52
R
40
$28
(
83
$53
S
41
$29
)
84
$54
T
42
$2A
»
85
$55
U
431
Table D-4— cont. Keystrokes and Corresponding Key
Codes Arranged With Key Codes in Numerical Order
Code
Key
Code
Key
Dec
Hex
Dec
Hex
86
$66
V
129
$81
<inv.> CTRL-A
87
$57
W
130
$82
<inv.> CTRL-B
88
$58
X
131
$83
<inv.> CTRL-C
89
$59
Y
132
$84
<inv.> CTRL-D
90
$5A
Z
133
$85
<inv.> CTRL-E
91
$5B
[
134
$86
<inv.> CTRL-F
92
$5C
\
135
$87
<inv.> CTRL-G
93
$5D
]
136
$88
<inv.> CTRL-H
94
$5E
•
137
$89
<inv.> CTRL-I
95
$5F
—
138
$8A
<inv.> CTRL-J
96
$60
CTRL-.
139
$88
<inv.> CTRL-K
97
$61
a
140
$8C
<inv.> CTRL-L
98
$62
b
141
$80
<inv.> CTRL-M
99
$63
c
142
$8E
<inv.> CTRL-N
100
$64
d
143
$8F
<inv.> CTRL-0
101
$65
e
144
$90
<inv.> CTRL-P
102
$66
f
145
$91
<inv.> CTRL-Q
103
$67
g
146
$92
<inv.> CTRL-R
104
$68
h
147
$93
<inv.> CTRL-S
105
$69
i
148
$94
<inv.> CTRL-T
106
$6A
J
149
$95
<inv.> CTRL-U
107
$68
k
150
$96
<inv.> CTRL-V
108
$6C
1
151
$97
<inv.> CTRL-W
109
$60
m
152
$98
<inv.> CTRL-X
110
$6E
n
153
$99
<inv.> CTRL-Y
111
$6F
o
154
$9A
<inv.> CTRL-Z
112
$70
P
155
$98
RETURN and CTRL-3
113
$71
q
156
$9C
DELETE
114
$72
r
157
$90
INSERT
115
$73
s
158
$9E
TAB
116
$74
t
159
$9F
SET
117
$75
u
160
$A0
<inv.> Space
118
$76
V
161
$A1
<inv.> !
119
$77
w
162
$A2
<inv.> "
120
$78
X
163
$A3
<inv.> #
121
$79
y
164
$A4
<inv.> $
122
$7A
z
165
$A5
<inv.> %
123
$78
CTRL-;
166
$A6
<inv.> &
124
$7C
1
167
$A7
<inv.> '
125
$70
CLEAR
168
$A8
<inv.>(
126
$7E
BACKS
169
$A9
<inv.> )
127
$7F
TAB
170
$AA
<inv.> *
128
$80
<inv.> CTRL-,
171
$AB
<inv.> -1-
432
Table D-4— cont. Keystrokes and Corresponding Key
Codes Arranged With Key Codes in Numerical Order
Code
Key
Code
Key
Dec
Hex
Dec
Hex
172
$AC
<inv.> ,
214
$D6
<inv.> V
173
$AD
<inv.>-
215
$D7
<inv.>W
174
SAE
<inv.> .
216
$D8
<inv.> X
175
$AF
<inv.> /
217
$D9
<inv.> Y
176
$B0
<inv.>
218
$DA
<inv.>Z
177
$81
<inv.> 1
219
$DB
<inv.> (
178
$82
<inv.> 2
220
$DC
<inv.> \
179
$83
<inv.> 3
221
$DD
<inv>l
180
$84
<inv.> 4
222
$DE
<inv.>»
181
$85
<inv.> 5
223
$DF
<inv.> —
182
$86
<inv.> 6
224
$E0
<inv.>CTRL-.
183
$87
<inv.> 7
225
$E1
<inv.> a
184
$88
<inv.> 8
226
$E2
<inv.> b
185
$89
<inv.> 9
227
$E3
<inv.>c
186
$BA
<inv.> :
228
$E4
<inv.>cl
187
$88
<inv.> ;
229
$E5
<inv.> e
188
$BC
<inv.> <
230
$E6
<inv.>f
189
$8D
<inv.> =
231
$E7
<inv.>g
190
$BE
<inv.> >
232
$E8
<inv.> h
191
$BF
<inv.> ?
233
$E9
<inv.> i
192
$C0
<inv.> @
234
$EA
<inv.> j
193
$C1
<inv.> A
235
$EB
<inv.> k
194
$C2
<inv.> B
236
$EC
<inv.> 1
195
$C3
<inv.> C
237
$ED
<inv.> m
196
$C4
<inv.> D
238
$EE
<inv.> n
197
$C5
<inv.> E
239
$EF
<inv.> o
198
$C6
<inv.> F
240
$F0
<inv.> p
199
$C7
<inv.> G
241
$F1
<inv.> q
200
$C8
<inv.> H
242
$F2
<inv.> r
201
$C9
<inv.> 1
243
$F3
<inv.> s
202
$CA
<inv.>J
244
$F4
<inv.>t
203
$C8
<inv.>K
245
$F5
<inv.> u
204
$CC
<inv.> L
246
$F6
<inv.> V
205
$CD
<inv.> M
247
$F7
<inv.> w
206
$CE
<inv.> N
248
$F8
<inv.> X
207
$CF
<inv.>0
249
$F9
<inv.> y
208
$D0
<inv.> P
250
$FA
<inv.> z
209
$D1
<inv.> Q
251
$F8
<inv.> CTRL-,
210
$D2
<inv.> R
252
$FC
<inv.>|
211
$D3
<inv.> S
253
$FD
CTRL-2
212
$D4
<inv.>T
254
$FE
CTRL-DELETE
213
$D5
<inv.> U
255
$FF
CTRL-INSERT
433
Appendix E
Screen RAM Addressing Ranges
for the ATARI Screen Modes
The tables in this appendix cite the starting and ending
addresses for the screen RAM. Modes included here are
through 8 and their full-screen counterparts, 17 through
24.
435
Table E-1 . Absolute Addresses for ATARI
BASIC Mode-0 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
40000
40039
$9C40
$9C67
Row 1
40040
40079
$9C68
$9C8F
Row 2
40080
40119
$9C90
$9CB7
Row 3
40120
40159
$9CB8
$9CDF
Row 4
40160
40199
$9CE0
$9007
Row 5
40200
40239
$9008
$9D2F
Row 6
40240
40279
$9030
$9057
Row 7
40280
40319
$9058
S9D7F
Row 8
40320
40359
$9080
$9DA7
Row 9
49360
40399
$9DA8
$9DCF
Row 10
40400
40439
$9DD0
$9DF7
Row 11
40440
40479
$9DF8
$9E1F
Row 12
40480
40519
$9E20
$9E47
Row 13
40520
40559
$9E48
$9E6F
Row 14
40560
40599
$9E70
$9E97
Row 15
40600
40639
$9E98
$9EBF
Row 16
40640
40679
$9EC0
$9EE7
Row 17
40680
40719
$9EE8
$9F0F
Row 18
40720
40759
$9F10
$9F37
Row 19
40760
40799
$9F38
$9F5F
Row 20
40800
40839
$9F60
$9F87
Row 21
40840
40879
$9F88
$9FAF
Row 22
40880
40919
$9FB0
$9FD7
Row 23
40920
40959
$9FD8
S9FFF
436
Table E-2. Absolute Addresses for ATARI
BASIC Mode-1 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
40320
40339
$9D80
$9D93
Row 1
40340
40359
$9D94
$9DA7
Row 2
40360
40379
$9DA8
$9DBB
Row 3
40380
40399
$9DBC
$9DCF
Row 4
40400
40419
$9DD0
S9DE3
Row 5
40420
40439
$9DE4
$9DF7
Row 6
40440
40459
$9DF8
$9E0B
Row 7
40460
40479
$9E0C
$9E1F
Row 8
40480
40499
$9E20
$9E33
Row 9
40500
40519
$9E34
S9E47
Row 10
40520
40539
$9E48
$9E5B
Row 11
40540
40559
$9E5C
$9E6F
Row 12
40560
40579
$9E70
$9E83
Row 13
40580
40599
$9E84
$9E97
Row 14
40600
40619
$9E98
$9EAB
Row 15
40620
40639
S9EAC
$9EBF
Row 16
40640
40659
$9EC0
$9ED3
Row 17
40660
40679
$9ED4
$9EE7
Row 18
40680
40699
$9EE8
$9EFB
Row 19
40700
40719
S9EFC
$9F0F
TextV
Vindow Begin
5 Here
Row
40800
40839
$9F60
S9F87
Row 1
40840
40879
$9F88
S9FAF
Row 2
40880
40919
$9FB0
$9FD7
Row 3
40920
40959
$9FD8
$9FFF
437
Table E-3. Absolute Addresses for ATARI
BASIC Mode-17 Screen Display
Row
Decimal
Hexadecimal {
Start
End
Start
End
Row
40320
40339
$9D80
$9093
Row 1
40340
40359
$9094
$9DA7
Row 2
40360
40379
$9DA8
$9DBB
Row 3
40380
40399
$9DBC
$9DCF
Row 4
40400
40419
$9000
$9DE3
Row 5
40420
40439
$9DE4
$9DF7
Row 6
40440
40459
$9DF8
$9E0B
Row 7
40460
40479
$9E0C
$9E1F
Row 8
40480
40499
$9E20
$9E33
Row 9
40500
40519
$9E34
$9E47
Row 10
40520
40539
$9E48
$9E5B
Row 11
40540
40559
$9E5C
$9E6F
Row 12
40560
40579
$9E70
$9E83
Row 13
40580
40599
$9E84
S9E97
Row 14
40600
40619
$9E98
$9EAB
Row 15
40620
40639
$9EAC
$9EBF
Row 16
40640
40659
$9EC0
$9ED3
Row 17
40660
40679
$9ED4
$9EE7
Row 18
40680
40699
$9EE8
$9EFB
Row 19
40700
40719
$9EFC
$9F0F
Row 20
40720
40739
$9F10
$9F23
Row 21
40740
40759
$9F24
$9F37
Row 22
40760
40779
$9F38
$9F4B
Row 23
40780
40799
S9F4C
$9F5F
438
Table E-4. Absolute Addresses for ATARI
BASIC Mode-2 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
RowO
Row 1
Row 2
Row 3
Row 4
Row 5
Row 6
Row 7
Row 8
Row 9
40560
40580
40600
40620
40640
40660
40680
40700
40720
40740
40579
40599
40619
40639
40659
40679
40699
40719
40739
40759
$9E70
$9E84
$9E98
$9EAC
$9EC0
$9ED4
$9EE8
$9EFC
$9F10
$9F24
$9E83
S9E97
$9EAB
$9EBF
$9ED3
$9EE7
$9EFB
$9F0F
$9F23
$9F37
Text Window Addressing Begins Here |
RowO
Row 1
Row 2
Row 3
40800
40840
40880
40920
40839
40879
40919
40959
$9F60
$9F88
$9FB0
$9FD8
S9F87
$9FAF
$9FD7
$9FFF
Table E-5. Absolute Addresses for ATARI
BASIC Mode-18 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
40560
40579
S9E70
$9E83
Row 1
40580
40599
$9E84
$9E97
Row 2
40600
40619
$9E98
$9EAB
Row 3
40620
40639
$9EAC
$9EBF
Row 4
40640
40659
$9EC0
$9ED3
Row 5
40660
40679
$9ED4
$9EE7
Row 6
40680
40699
$9EE8
S9EFB
Row 7
40700
40719
$9EFC
$9F0F
Row 8
40720
40739
$9F10
$9F23
Row 9
40740
40759
$9F24
S9F37
Row 10
40760
40779
$9F38
S9F4B
Row 11
40780
40799
$9F4C
S9F5F
439
Table E-6. Absolute Addresses for ATARI
BASIC Mode-3 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
40560
40569
$9E70
$9E79
Row 1
40570
40579
$9E7A
$9E83
Row 2
40580
40589
$9E84
$9E8D
Row 3
40590
40599
$9E8E
S9E97
Row 4
40600
40609
$9E98
$9EA1
Row 5
40610
40619
$9EA2
$9EAB
Row 6
40620
40629
S9EAC
$9EB5
Row 7
40630
40639
$9EB6
S9EBF
Row 8
40640
40649
$9EC0
$9EC9
Row 9
40650
40659
$9ECA
$9ED3
Row 10
40660
40669
$9ED4
$9EDD
Row 11
40670
40679
$9EDE
$9EE7
Row 12
40680
40689
$9EE8
$9EF1
Row 13
40690
40699
$9EF2
S9EFB
Row 14
40700
40709
S9EFC
$9F05
Row 15
40710
40719
$9F06
S9F0F
Row 16
40720
40729
$9F10
$9F19
Row 17
40730
40739
S9F1A
$9F23
Row 18
40740
40749
$9F24
$9F2D
Row 19
40750
40759
$9F2E
$9F37
Text windON
N addressing
segins here
Row
40800
40839
S9F60
$9F87
Row 1
40840
40879
$9F88
$9FAF
Row 2
40880
40919
$9FB0
S9FD7
Row 3
40920
40959
$9FD8
$9FFF
440
Table E-7. Absolute Addresses for ATARI
BASIC Mode-1 9 Screen Display
Row
Decimal
Hexadecimal |
Start
End
Start
End
Row
40560
40569
$9E70
$9E79
Row 1
40570
40579
$9E7A
$9E83
Row 2
40580
40589
$9E84
$9E8D
Row 3
40590
40599
$9E8E
$9E97
Row 4
40600
40609
$9E98
$9EA1
Row 5
40610
40619
$9EA2
$9EAB
Row 6
40620
40629
$9EAC
$9EB5
Row 7
40630
40639
$9EB6
$9EBF
Row 8
40640
40649
S9EC0
$9EC9
Row 9
40650
40659
$9ECA
$9ED3
Row 10
40660
40669
$9ED4
$9E0D
Row 11
40670
40679
$9EDE
S9EE7
Row 12
40680
40689
$9EE8
$9EFI
Row 13
40690
40699
$9EF2
$9EFB
Row 14
40700
40709
$9EFC
$9F05
Row 15
40710
40719
$9F06
$9F0F
Row 16
40720
40729
$9F10
$9F19
Row 17
40730
40739
$9F1A
$9F23
Row 18
40740
40749
S9F24
$9F2D
Row 19
40750
40759
$9F2E
$9F37
Row 20
40760
40769
$9F38
$9F41
Row 21
40770
40779
$9F42
$9F4B
Row 22
40780
40789
$9F4C
$9F55
Row 23
40790
40799
$9F56
$9F5F
441
Table E-8. Absolute Addresses for ATARI
BASIC Mode-4 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
40320
40329
$9080
$9089
Row 1
40330
40339
$9D8A
$9093
Row 2
40340
40349
$9094
$9D9D
Row 3
40350
40359
$9D9E
$9DA7
Row 4
40360
40369
$9DA8
$9DB1
Row 5
40370
40379
$9DB2
$9DBB
Row 6
40380
40389
$9DBC
$9DC5
Row 7
40390
40399
$9DC6
$9DCF
Row 8
40400
40409
$9DD0
$9009
Row 9
40410
40419
$9DDA
$9DE3
Row 10
40420
40429
$9DE4
$9DED
Row 11
40430
40439
$9DEE
$9DF7
Row 12
40440
40449
$9DF8
$9E01
Row 13
40450
40459
$9E02
$9E0B
Row 14
40460
40469
$9E0C
$9E15
Row 15
40470
40479
$9E16
$9E1F
Row 16
40480
40489
$9E20
$9E29
Row 17
40490
40499
$9E2A
$9E33
Row 18
40500
40509
$9E34
$9E3D
Row 19
40510
40519
$9E3E
$9E47
Row 20
40520
40529
$9E48
$9E51
Row 21
40530
40539
$9E52
$9E5B
Row 22
40540
40549
$9E5C
$9E65
Row 23
40550
40559
$9E66
$9E6F
Row 24
40560
40569
$9E70
$9E79
Row 25
40570
40579
$9E7A
$9E83
Row 26
40580
40589
$9E84
$9E8D
Row 27
40590
40599
$9E8E
$9E97
Row 28
40600
40609
$9E98
$9EA1
Row 29
40610
40619
$9EA2
$9EAB
Row 30
40620
40629
$9EAC
$gEB5
Row 31
40630
40639
$9EB6
$9EBF
Row 32
40640
40649
$9EC0
$9EC9
Row 33
40650
40659
$9ECA
$9ED3
Row 34
40660
40669
$9ED4
$9EDD
Row 35
40670
40679
$9EDE
$9EE7
442
Table E-8— cont. Absolute Addresses for ATARI
BASIC Mode-4 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row 36
Row 37
Row 38
Row 39
40680
40690
40700
40710
40689
40699
40709
40719
$9EE8
$9EF2
$9EFC
$9F06
$9EF1
$9EFB
$9F05
$9F0F
Text window addressing begins here
Row
Row 1
Row 2
Row 3
40800
40840
40880
40920
40839
40879
40919
40959
$9F60
$9F88
$9FB0
$9FD8
$9F87
$9FAF
$9FD7
$9FFF
443
Table E-9. Absolute Addresses for ATARI
BASIC Mode-20 Screen Display
Row
Decimal
Hexadecimal |
Start
End
Start
End
Row
40320
40329
$9080
$9089
Row 1
40330
40339
$9D8A
$9093
Row 2
40340
40349
$9094
$9D9D
Row 3
40350
40359
$9D9E
$9DA7
Row 4
40360
40369
$9DA8
$9081
Row 5
40370
40379
$9DB2
$9DBB
Row 6
40380
40389
$9DBC
$9DC5
Row 7
40390
40399
$9DC6
$9DCF
Row 8
40400
40409
$9DD0
$9009
Row 9
40410
40419
$9DDA
$9DE3
Row 10
40420
40429
$90E4
$9DED
Row 11
40430
40439
$9DEE
$9DF7
Row 12
40440
40449
$9DF8
$9E01
Row 13
40450
40459
$9E02
$9E0B
Row 14
40460
40469
$9E0C
$9E15
Row 15
40470
40479
$9E16
$9E1F
Row 16
40480
40489
$9E20
$9E29
Row 17
40490
40499
$9E2A
$9E33
Row 18
40500
40509
$9E34
$9E3D
Row 19
40510
40519
$9E3E
$9E47
Row 20
40520
40529
$9E48
$9E51
Row 21
40530
40539
$9E52
$9E5B
Row 22
40540
40549
$9E5C
$9E65
Row 23
40550
40559
$9E66
$9E6F
Row 24
40560
40569
$9E70
S9E79
Row 25
40570
40579
$9E7A
$9E83
Row 26
40580
40589
$9E84
$9E8D
Row 27
40590
40599
$9E8E
$9E97
Row 28
40600
40609
$9E98
$9EA1
Row 29
40610
40619
$9EA2
$9EAB
Row 30
40620
40629
$9EAC
$9EB5
Row 31
40630
40639
$9EB6
$9EBF
Row 32
40640
40649
$9EC0
$9EC9
Row 33
40650
40659
$9ECA
$9ED3
Row 34
40660
40669
$9ED4
$9EDD
Row 35
40670
40679
$9EDE
$9EE7
444
Table E-9— cont. Absolute Addresses for ATARI
BASIC Mode-20 Screen Display
Row
Decimal
Hexadecimal |
Start
End
Start
End
Row 36
40680
40689
$9EE8
$9EF1
Row 37
40690
40699
$9EF2
$9EFB
Row 38
40700
40709
$9EFC
$9F05
Row 39
40710
40719
$9F06
$9F0F
Row 40
40720
40729
$9F10
S9F19
Row 41
40730
40739
$9F1A
S9F23
Row 42
40740
40749
$9F24
$9F2D
Row 43
40750
40759
$9F2E
S9F37
Row 44
40760
40769
$9F38
$9F41
Row 45
40770
40779
$9F42
$9F4B
Row 46
40780
40789
$9F4C
$9F55
Row 47
40790
40799
$9F56
$9F5F
445
Table E-10. Absolute Addresses for ATARI
BASIC Mode-5 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
39840
39859
$9BA0
$9883
Row 1
39860
39879
$9BB4
$9BC7
Row 2
39880
39899
$9BC8
$9BDB
Row 3
39900
39919
$9BDC
$9BEF
Row 4
39920
39939
$9BF0
$9C03
Row 5
39940
39959
$9C04
$9C17
Row 6
39960
39979
$9C18
$9C2B
Row 7
39980
39999
$9C2C
$9C3F
Row 8
40000
40019
$9C40
$9C53
Row 9
40020
40039
$9C54
$9C67
Row 10
40040
40059
$9C68
$9C7B
Row 11
40060
40079
$9C7C
$9C8F
Row 12
40080
40099
$9C90
$9CA3
Row 13
40100
40119
$9CA4
$9CB7
Row 14
40120
40139
$9CB8
$9CCB
Row 15
40140
40159
$9CCC
$9CDF
Row 16
40160
40179
$9CE0
$9CF3
Row 17
40180
40199
$9CF4
$9007
Row 18
40200
40219
S9D08
$901 B
Row 19
40220
40239
$9D1C
$9D2F
Row 20
40240
40259
$9030
$9043
Row 21
40260
40279
$9044
$9057
Row 22
40280
40299
$9058
$9D6B
Row 23
40300
40319
$9D6C
$9D7F
Row 24
40320
40339
$9080
$9093
Row 25
40340
40359
$9094
$9DA7
Row 26
40360
40379
$9DA8
$9DBB
Row 27
40380
40399
$9DBC
$9DCF
Row 28
40400
40419
$9000
$9DE3
Row 29
40420
40439
$9DE4
$9DF7
Row 30
40440
40459
$9DF8
S9E0B
Row 31
40460
40479
$9E0C
$9E1F
Row 32
40480
40499
$9E20
$9E33
Row 33
40500
40519
$9E34
$9347
Row 34
40520
40539
$9E48
$9E5B
446
Table E-10— cont. Absolute Addresses for ATARI
BASIC Mode-5 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row 35
Row 36
Row 37
Row 38
Row 39
40540
40560
40580
40600
40620
40559
40579
40599
40619
40639
$9E5C
$9E70
$9E84
$9E98
$9EAC
$9E6F
$9E83
$9E97
$9EAB
$9EBF
Text window addressing begins here
Row
Row 1
Row 2
Row 3
40800
40840
40880
40920
40839
40879
40919
40959
$9F60
$9F88
$9FB0
$9FD8
$9F87
$9FAF
$9FD7
$9FFF
447
Table E-1 1 . Absolute Addresses for ATARI
BASIC Mode-21 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
39840
39859
$9BA0
$9BB3
Row 1
39860
39879
$9BB4
$9BC7
Row 2
39880
39899
$9BC8
$9BDB
Row 3
39900
39919
$9BDC
$9BEF
Row 4
39920
39939
$9BF0
$9C03
Row 5
39940
39959
$9C04
$9C17
Row 6
39960
39979
S9C18
$9C2B
Row 7
39980
39999
$9C2C
$9C3F
Row 8
40000
40019
$9C40
$9C53
Row 9
40020
40039
S9C54
$9C67
Row 10
40040
40059
$9C68
$9C7B
Row 11
40060
40079
$9C7C
$9C8F
Row 12
40080
40099
$9C90
$9CA3
Row 13
40100
40119
$9CA4
$9CB7
Row 14
40120
40139
S9CB8
$9CCB
Row 15
40140
40159
$9CCC
$9CDF
Row 16
40160
40179
$9CE0
$9CF3
Row 17
40180
40199
S9CF4
$9007
Row 18
40200
40219
$9008
$901 B
Row 19
40220
40239
$9D1C
$9D2F
Row 20
40240
40259
$9030
$9043
Row 21
40260
40279
$9044
$9057
Row 22
40280
40299
$9058
$906B
Row 23
40300
40319
$9D6C
$9D7F
Row 24
40320
40339
$9080
$9093
Row 25
40340
40359
$9094
$9DA7
Row 26
40360
40379
$9DA8
$9DBB
Row 27
40380
40399
$9DBC
$90CF
Row 28
40400
40419
$9000
$9DE3
Row 29
40420
40439
$9DE4
$9DF7
Row 30
40440
40459
$9DF8
$9E0B
Row 31
40460
40479
$9E0C
$9E1F
Row 32
40480
40499
$9E20
$9E33
Row 33
40500
40519
$9E34
$9E47
Row 34
40520
40539
$9E48
$9E5B
Row 35
40540
40559
$9E5C
$9E6F
448
Table E-1 1 — cont. Absolute Addresses for ATARI
BASIC Mode-21 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row 36
40560
40579
$9E70
$9E83
Row 37
40580
40599
$9E84
$9E97
Row 38
40600
40619
$9E98
$9EAB
Row 39
40620
40639
$9EAC
$9EBF
Row 40
40640
40659
$9EC0
$9ED3
Row 41
40660
40679
$9ED4
$9EE7
Row 42
40680
40699
$9EE8
$9EFB
Row 43
40700
40719
$9EFC
$9F0F
Row 44
40720
40739
$9F10
$9F23
Row 45
40740
40759
$9F24
$9F37
Row 46
40760
40779
$9F38
$9F4B
Row 47
40780
40799
$9F4C
$9F5F
449
Table E-12. Absolute Addresses for ATARI
BASIC Mode-6 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row
38880
38899
$97E0
$97F3
Row 1
38900
38919
$97F4
S9807
Row 2
38920
38939
$9808
$9818
Row 3
38940
38959
$981 C
$982F
Row 4
38960
38979
$9830
$9843
Row 5
38980
38999
$9844
$9857
Row 6
39000
39019
$9858
$9868
Row 7
39020
39039
$986C
$987F
Row 8
39040
39059
$9880
$9893
Row 9
39060
39079
$9894
$98A7
Row 10
39080
39099
$98A8
$9888
Row 11
39100
39119
$98BC
$98CF
Row 12
39120
39139
$98D0
$98E3
Row 13
39140
39159
$98E4
$98F7
Row 14
39160
39179
$98F8
$9908
Row 15
39180
39199
$990C
$991 F
Row 16
39200
39219
$9920
$9933
Row 17
39220
39239
$9934
$9947
Row 18
39240
39259
$9948
$9958
Row 19
39260
39279
$995C
$996F
Row 20
39280
39299
$9970
$9983
Row 21
39300
39319
$9984
$9997
Row 22
39320
39339
$9998
$99AB
Row 23
39340
39359
$99AC
$99BF
Row 24
39360
39379
$99C0
$99D3
Row 25
39380
39399
$99D4
$99E7
Row 26
39400
39419
$99E8
$99FB
Row 27
39420
39439
$99FC
$9A0F
Row 28
39440
39459
$9A10
$9A23
Row 29
39460
39479
$9A24
$9A37
Row 30
39480
39499
$9A38
$9A4B
Row 31
39500
39519
$9A4C
$9A5F
Row 32
39520
39539
$9A60
$9A73
Row 33
39540
39559
$9A74
$9A87
Row 34
39560
39579
$9A88
$9A9B
Row 35
39580
39599
$9A9C
$9AAF
Row 36
39600
39619
$9AB0
$9AC3
Row 37
39620
39639
$9AC4
$9AD7
Row 38
39640
39659
$9AD8
$9AEB
Row 39
39660
39679
$9AEC
$9AFF
Row 40
39680
39699
$9800
$9813
Row 41
39700
39719
$9814
$9B27
Row 42
39720
39739
$9828
$9B3B
Row 43
39740
39759
$9B3C
$9B4F
450
Table E-1 2— cont. Absolute Addresses for ATARI
BASIC Mode-6 Screen Display
Row
Decimal
Hexadecimal
Start
End
Start
End
Row 44
39760
39779
$9850
$9863
Row 45
39780
39799
$9864
$9877
Row 46
39800
39819
$9878
$9B8B
Row 47
39820
39839
$9B8C
$9B9F
Row 48
39840
39859
$9BA0
$9BB3
Row 49
39860
39879
$9BB4
$9BC7
Row 50
39880
39899
$9BC8
$9BDB
Row 51
39900
39919
$9BDC
$9BEF
Row 52
39920
39939
$9BF0
$9C03
Row 53
39940
39959
$9C04
$9C17
Row 54
39960
39979
$9C18
$9C2B
Row 55
39980
39999
$9C2C
$9C3F
Row 56
40000
40019
$9C40
$9C53
Row 57
40020
40039
$9C54
$9C67
Row 58
40040
40059
$9C68
$9C7B
Row 59
40060
40079
$9C7C
$9C8F
Row 60
40080
40099
$9C90
$9CA3
Row 61
40100
40119
$9CA4
$9CB7
Row 62
40120
40139
$9CB8
$9CCB
Row 63
40140
40159
$9CCC
$9CDF
Row 64
40160
40179
$9CE0
$9CF3
Row 65
40180
40199
$9CF4
$9007
Row 66
40200
40219
$9D08
$9D1B
Row 67
40220
40239
$9D1C
$9D2F
Row 68
40240
40259
$9D30
$9D43
Row 69
40260
40279
$9D44
$9057
Row 70
40280
40299
$9D58
$9D6B
Row 71
40300
40319
$9D6C
$9D7F
Row 72
40320
40339
$9D80
$9093
Row 73
40340
40359
S9D94
$9DA7
Row 74
40360
40379
$9DA8
$9DBB
Row 75
40380
40399
$9DBC
$9DCF
Row 76
40400
40419
$9DD0
$9DE3
Row 77
40420
40439
$9DE4
$9DF7
Row 78
40440
40459
$9DF8
$9E0B
Row 79
40460
40479
$9E0C
$9E1F
Text windo
w addressing
begins here
Row
40800
40839
$9F60
$9F87
Row 1
40840
40879
$9F88
$9FAF
Row 2
40880
40919
$9FB0
$9FD7
Row 3
40920
40959
$9FD8
$9FFF
451
Table E-13. Absolute Addresses for ATARI
BASIC Mode-22 Screen Display
Row
Decimal
Hexadecimal |
Start
End
Start
End
Row
38880
38899
S97E0
$97F3
Row 1
38900
38919
$97F4
$9807
Row 2
38920
38939
$9808
$981 B
Row 3
38940
38959
$981 C
$982F
Row 4
38960
38979
$9830
$9843
Row 5
38980
38999
S9844
$9857
Row 6
39000
39019
$9858
$986B
Row 7
39020
39039
$986C
$987F
Row 8
39040
39059
$9880
$9893
Row 9
39060
39079
$9894
$98A7
Row 10
39080
39099
$98A8
$98BB
Row 11
39100
39119
$98BC
$98CF
Row 12
39120
39139
$9800
$98E3
Row 13
39140
39159
$98E4
$98F7
Row 14
39160
39179
$98F8
$9908
Row 15
39180
39199
$990C
$991 F
Row 16
39200
39219
$9920
$9933
Row 17
39220
39239
$9934
$9947
Row 18
39240
39259
$9948
$995B
Row 19
39260
39279
$995C
$996F
Row 20
39280
39299
$9970
$9983
Row 21
39300
39319
$9984
$9997
Row 22
39320
39339
$9998
$99AB
Row 23
39340
39359
$99AC
$99BF
Row 24
39360
39379
$99C0
$9903
Row 25
39380
39399
$99D4
$99E7
Row 26
39400
39419
$99E8
$99FB
Row 27
39420
39439
$99FC
$9A0F
Row 28
39440
39459
$9A10
$9A23
Row 29
39460
39479
$9A24
$9A37
Row 30
39480
39499
$9A38
$9A4B
Row 31
39500
39519
$9A4C
$9A5F
Row 32
39520
39539
$9A60
$9A73
Row 33
39540
39559
$9A74
$9A87
Row 34
39560
39579
$9A88
$9A9B
452
Table E-13— cont. Absolute Addresses for ATARI
BASIC Mode-22 Screen Display
Row
Decimal
Hexadecimal |
Start
End
Start
End
Row 35
39580
39599
$9A9C
$9AAF
Row 36
39600
39619
$9AB0
$9AC3
Row 37
39620
39639
$9AC4
$9AD7
Row 38
39640
39659
$9AD8
$9AEB
Row 39
39660
39679
$9AEC
$9AFF
Row 40
39680
39699
$9B00
$9B13
Row 41
39700
39719
$9B14
$9B27
Row 42
39720
39739
$9B28
$9B3B
Row 43
39740
39759
$9B3C
$9B4F
Row 44
39760
39779
$9B50
$9B63
Row 45
39780
39799
$9B64
$9B77
Row 46
39800
39819
$9B78
$9B8B
Row 47
39820
39839
$9B8C
$9B9F
Row 48
39840
39859
$9BA0
$9BB3
Row 49
39860
39879
$9BB4
$9BC7
Row 50
39880
39899
$9BC8
$9BDB
Row 51
39900
39919
$9BDC
$9BEF
Row 52
39920
39939
$9BF0
$9C03
Row 53
39940
39959
$9C04
$9C17
Row 54
39960
39979
$9C18
$9C2B
Row 55
39980
39999
$9C2C
$9C3F
Row 56
40000
40019
$9C40
$9C53
Row 57
40020
40039
$9C54
$9C67
Row 58
40040
40059
$9C68
$9C7B
Row 59
40060
40079
$9C7C
$9C8F
Row 60
40080
40099
S9C90
S9CA3
Row 61
40100
40119
$9CA4
$9CB7
Row 62
40120
40139
$9CB8
$9CCB
Row 63
40140
40159
$9CCC
$9CDF
Row 64
40160
40179
$9CE0
$9CF3
Row 65
40180
40199
$9CF4
$9007
Row 66
40200
40219
$9008
$901 B
Row 67
40220
40239
$9D1C
$9Q2F
Row 68
40240
40259
$9030
$9043
Row 69
40260
40279
$9044
$9057
453
Table E-1 3— cont. Absolute Addresses for ATARI
BASIC Mode-22 Screen Display
Row
Decimal
Hexadecimal |
Start
End
Start
End
Row 70
40280
40299
$9058
$9D6B
Row 71
40300
40319
$9D6C
$9D7F
Row 72
40320
40339
$9080
$9D93
Row 73
40340
40359
$9094
$9DA7
Row 74
40360
40379
$9DA8
$9DBB
Row 75
40380
40399
$9DBC
$9DCF
Row 76
40400
40419
$9DD0
$9DE3
Row 77
40420
40439
$9DE4
$9DF7
Row 78
40440
40459
$9DF8
$9E0B
Row 79
40460
40479
$9E0C
$9E1F
Row 80
40480
40499
$9E20
$9E33
Row 81
40500
40519
$9E34
$9E47
Row 82
40520
40539
$9E48
$9E5B
Row 83
40540
40559
$9E5C
$9E6F
Row 84
40560
40579
$9E70
$9E83
Row 85
40580
40599
$9E84
$9E97
Row 86
40600
40619
S9E98
$9EAB
Row 87
40620
40639
$9EAC
$9EBF
Row 88
40640
40659
$9EC0
$9ED3
Row 89
40660
40679
$9ED4
$9EE7
Row 90
40680
40699
$9EE8
S9EFB
Row 91
40700
40719
$9EFC
$9F0F
Row 92
40720
40739
$9F10
S9F23
Row 93
40740
40759
$9F24
$9F37
Row 94
40760
40779
$9F38
$9F4B
Row 95
40780
40799
$9F4C
$9F5F
454
Table E-1 4. Absolute Addresses for ATARI
BASIC Mode-7 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line
36960
36999
$9060
$9087
Line 1
37000
37039
$9088
$90AF
Line 2
37040
37079
$9060
$9007
Line 3
37080
37119
$9008
$90FF
Line 4
37120
37159
$9100
$9127
Line 5
37160
37199
$9128
$91 4F
Line 6
37200
37239
$9150
$9177
Line 7
37240
37279
$9178
$91 9F
Line 8
37280
37319
$91 AO
$91 C7
Line 9
37320
37359
$91 C8
$91 EF
Line 10
37360
37399
$91 FO
$9217
Line 1 1
37400
37439
$9218
$923F
Line 12
37440
37479
$9240
$9267
Line 13
37480
37519
$9268
$928F
Line 14
37520
37559
$9290
$9287
Line 15
37560
37599
$9288
$92DF
Line 16
37600
37639
$92E0
$9307
Line 17
37640
37679
$9308
$932F
Line 18
37680
37719
$9330
$9E57
Line 19
37720
37759
$9358
$937F
Line 20
37760
37799
$9380
$93A7
Line 21
37800
37839
$93A8
$93CF
Line 22
37840
37879
$9300
$93F7
Line 23
37880
37919
$93F8
$941 F
Line 24
37920
37959
$9420
$9447
Line 25
37960
37999
$9448
$946F
Line 26
38000
38039
$9470
$9497
Line 27
38040
38079
$9498
$94BF
Line 28
38080
38119
$94C0
$94E7
Line 29
38120
38159
$94E8
$950F
Line 30
38160
38199
$9510
$9537
Line 31
38200
38239
$9538
$955F
Line 32
38240
38279
$9560
$9587
Line 33
38280
38319
$9588
$95AF
Line 34
38320
38359
$9580
$9507
Line 35
38360
38399
$9508
$95FF
Line 36
38400
38439
$9600
$9627
Line 37
38440
38479
$9628
$964F
Line 38
38480
38519
$9650
$9677
Line 39
38520
38559
$9678
$969F
Line 40
38560
38599
$96A0
$96C7
Line 41
38600
38639
$96C8
$96EF
Line 42
38640
38679
$96F0
$9717
Line 43
38680
38719
$9718
$973F
455
Table E-14— cont. Absolute Addresses for ATARI
BASIC Mode-7 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 44
38720
38759
$9740
$9767
Line 45
38760
38799
$9768
$978F
Line 46
38800
38839
$9790
$9787
Line 47
38840
38879
$9788
$97DF
Line 48
38880
38919
$97E0
$9807
Line 49
38920
38959
$9808
$982F
Line 50
38960
38999
$9830
$9857
Line 51
39000
39039
$9858
$987F
Line 52
39040
39079
$9880
$98A7
Line 53
39080
39119
$98A8
$98CF
Line 54
39120
39159
$9800
$98F7
Line 55
39160
39199
$98F8
$991 F
Line 56
39200
39239
$9920
$9947
Line 57
39240
39279
$9948
$996F
Line 58
39280
39319
$9970
$9997
Line 59
39320
39359
$9998
$99BF
Line 60
39360
39399
$99C0
$99E7
Line 61
39400
39439
$99E8
$9A0F
Line 62
39440
39479
$9A10
$9A37
Line 63
39480
39519
$9A38
$9A5F
Line 64
39520
39559
$9A60
$9A87
Line 65
39560
39599
$9A88
$9AAF
Line 66
39600
39639
$9AB0
$9AD7
Line 67
39640
39679
$9AD8
$9AFF
Line 68
39680
39719
$9800
$9827
Line 69
39720
39759
$9828
$9B4F
Line 70
39760
39799
$9850
$9877
Line 71
39800
39839
$9878
$9B9F
Line 72
39840
39879
$9BA0
$9BC7
Line 73
39880
39919
$9BC8
$9BEF
Line 74
39920
39959
$9BF0
$9C17
Line 75
39960
39999
$9C18
$9C3F
Line 76
40000
40039
$9C40
$9C67
Line 77
40040
40079
$9C68
$9C8F
Line 78
40080
40119
$9C90
$9CB7
Line 79
40120
40159
$9CB8
$9CDF
Text windov
V addressing t
>egins here
Line
40800
40839
$9F60
$9F87
Line 1
40840
40879
$9F88
$9FAF
Line 2
40880
40919
$9FB0
$9FD7
Line 3
40920
40959
$9FD8
$9FFF
456
Table E-1 5. Absolute Addresses for ATARI
BASIC Mode-23 Screen Display
Line
Decimal
Hexadecimal |
Start
End
Start
End
Line
36960
36999
$9060
$9087
Line 1
37000
37039
$9088
S90AF
Line 2
37040
37079
$9080
$90D7
Line 3
37080
37119
$9008
$90FF
Line 4
37120
37159
S9100
$9127
Line 5
37160
37199
$9128
$914F
Line 6
37200
37239
$9150
$9177
Line 7
37240
37279
$9178
$91 9F
Line 8
37280
37319
$91A0
$91C7
Line 9
37320
37359
$91 C8
$91EF
Line 10
37360
37399
$91 FO
$9217
Line 1 1
37400
37439
$9218
$923F
Line 12
37440
37479
$9240
$9267
Line 13
37480
37519
$9268
$928F
Line 14
37520
37559
$9290
$9287
Line 1 5
37560
37599
$9288
$92DF
Line 16
37600
37639
$92E0
$9307
Line 17
37640
37679
$9308
$932F
Line 18
37680
37719
$9330
$9357
Line 19
37720
37759
$9358
$937F
Line 20
37760
37799
$9380
$93A7
Line 21
37800
37839
$93A8
$93CF
Line 22
37840
37879
$9300
$93F7
Line 23
37880
37919
$93F8
$941 F
Line 24
37920
37959
$9420
$9447
Line 25
37960
37999
$9448
$946F
Line 26
38000
38039
$9470
$9497
Line 27
38040
38079
$9498
$94BF
Line 28
38080
38119
$94C0
$94E7
Line 29
38120
38159
$94E8
$950F
Line 30
38160
38199
$9510
$9537
Line 31
38200
38239
$9538
$955F
Line 32
38240
38279
$9560
$9587
Line 33
38280
38319
$9588
$95AF
Line 34
38320
38359
$9580
$9507
457
Table E-1 5— cont. Absolute Addresses for ATARI
BASIC Mode-23 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 35
38360
38399
$9508
$95FF
Line 36
38400
38439
S9600
$9627
Line 37
38440
38479
$9628
$964F
Line 38
38480
38519
$9650
$9677
Line 39
38520
38559
$9678
$969F
Line 40
38560
38599
$96A0
$96C7
Line 41
38600
38639
$96C8
$96EF
Line 42
38640
38679
$96F0
$9717
Line 43
38680
38719
$9718
$973F
Line 44
38720
38759
$9740
$9767
Line 45
38760
38799
$9768
$978F
Line 46
38800
38839
$9790
$9787
Line 47
38840
38879
$97B8
$970F
Line 48
38880
38919
$97E0
$9807
Line 49
38920
38959
$9808
$982F
Line 50
38960
38999
$9830
$9857
Line 51
39000
39039
$9858
$987F
Line 52
39040
39079
$9880
$98A7
Line 53
39080
39119
$98A8
$98CF
Line 54
39120
39159
$9800
$98F7
Line 55
39160
39199
$98F8
$991 F
Line 56
39200
39239
$9920
$9947
Line 57
39240
39279
$9948
$996F
Line 58
39280
39319
$9970
$9997
Line 59
39320
39359
$9998
$99BF
Line 60
39360
39399
$99C0
$99E7
Line 61
39400
39439
$99E8
$9A0F
Line 62
39440
39479
$9A10
$9A37
Line 63
39480
39519
$9A38
$9A5F
Line 64
39520
39559
$9A60
$9A87
Line 65
39560
39599
$9A88
$9AAF
Line 66
39600
39639
$9AB0
$9A07
Line 67
39640
39679
$9A08
$9AFF
Line 68
39680
39719
$9800
$9827
Line 69
39720
39759
$9828
$9B4F
458
Table E-1 5— cont. Absolute Addresses for ATARI
BASIC Mode-23 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 70
39760
39799
$9850
$9B77
Line 71
39800
39839
$9878
$9B9F
Line 72
39840
39879
$9BA0
$9BC7
Line 73
39880
39919
$9BC8
$9BEF
Line 74
39920
39959
$9BF0
$9C17
Line 75
39960
39999
$9C18
$9C3F
Line 76
40000
40039
$9C40
$9C67
Line 77
40040
40079
$9C68
$9C8F
Line 78
40080
40119
$9C90
$9CB7
Line 79
40120
40159
$9CB8
$9CDF
Line 80
40160
40199
$9CE0
$9007
Line 81
40200
40239
$9D08
$9D2F
Line 82
40240
40279
$9030
$9057
Line 83
40280
40319
$9058
$9D7F
Line 84
40320
40359
$9D80
$9DA7
Line 85
40360
40399
$9DA8
$9DCF
Line 86
40400
40439
$9DD0
$9DF7
Line 87
40440
40479
$9DF8
$9E1F
Line 88
40480
40519
$9E20
$9E47
Line 89
40520
40559
$9E48
$9E6F
Line 90
40560
40599
$9E70
$9E97
Line 91
40600
40639
$9E98
$9EBF
Line 92
40640
40679
$9EC0
$9EE7
Line 93
40680
40719
$9EE8
$9F0F
Line 94
40720
40759
$9F10
$9F37
Line 95
40760
40799
$9F38
$9F5F
459
Table E-1 6. Absolute Addresses for ATARI
BASIC Mode-8 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line
33104
33143
$8150
$8177
Line 1
33144
33183
$8178
$81 9F
Line 2
33184
33223
$81 AO
$81 C7
Line 3
33224
33263
$81 C8
$81 EF
Line 4
33264
33303
$81 FO
$8217
Line 5
33304
33343
$8218
$823F
Line 6
33344
33383
$8240
$8267
Line 7
33384
33423
$8268
$828F
Line 8
33424
33463
S8290
$82B7
Line 9
33464
33503
$82B8
S82DF
Line 10
33504
33543
$82E0
$8307
Line 1 1
33544
33583
$8308
$832F
Line 12
33584
33623
$8330
$8357
Line 13
33624
33663
$8358
$837F
Line 14
33664
33703
$8380
$83A7
Line 15
33704
33743
$83A8
$83CF
Line 16
33744
33783
$8300
$83F7
Line 17
33784
33823
S83F8
$841 F
Line 18
33824
33863
$8420
$8447
Line 19
33864
33903
S8448
$846F
Line 20
33904
33943
$8470
$8497
Line 21
33944
33983
$8498
$84BF
Line 22
33984
34023
$84C0
$84E7
Line 23
34024
34063
$8468
$850F
Line 24
34064
34103
$8510
$8537
Line 25
34104
34143
$8538
$855F
Line 26
34144
34183
$8560
$8587
Line 27
34184
34223
$8588
$85AF
Line 28
34224
34263
$8580
$8507
Line 29
34264
34303
$8508
$85FF
Line 30
34304
34343
$8600
$8627
Line 31
34344
34383
$8628
$864F
Line 32
34384
34423
$8650
$8677
Line 33
34424
34463
$8678
$869F
Line 34
34464
34503
$86A0
$86C7
Line 35
34504
34543
$86C8
$86EF
Line 36
34544
34583
$86F0
$8717
Line 37
34584
34623
$8718
$873F
Line 38
34624
34663
$8740
$8767
Line 39
34664
34703
$8768
$878F
Line 40
34704
34743
$8790
$8787
■
Line 41
34744
34783
$87B8
$87DF
460
Table E-1 6— cont. Absolute Addresses for ATARI
BASIC Mode-8 Screen Display
Line
Decimal
Hexadecimal |
Start
End
Start
End
Line 42
34784
34823
$87E0
$8807
Line 43
34824
34863
$8808
$882F
Line 44
34864
34903
$8830
$8857
Line 45
34904
34943
$8858
$887F
Line 46
34944
34983
$8880
$88A7
Line 47
34984
35023
$88A8
$88CF
Line 48
35024
35063
$88D0
$88F7
Line 49
35064
35103
S88F8
$891 F
Line 50
35104
35243
$8920
$8947
Line 51
35144
35183
$8948
$896F
Line 52
35184
35223
$8970
$8997
Line 53
35224
35263
$8998
$89BF
Line 54
35264
35303
S89C0
$89E7
Line 55
35304
35343
$89E8
$8A0F
Line 56
35344
35383
$8A10
$8A37
Line 57
35384
35423
$8A38
$8A5F
Line 58
35424
35463
S8A60
$8A87
Line 59
35464
35503
$8A88
$8AAF
Line 60
35504
35543
$8AB0
$8AD7
Line 61
35544
35583
$8AD8
$8AFF
Line 62
35584
35623
$8800
$8B27
Line 63
35624
35663
$8B28
$8B4F
Line 64
35664
35703
$8850
$8B77
Line 65
35704
35743
$8B78
$8B9F
Line 66
35744
35783
$8BA0
$8BC7
Line 67
35784
35823
S8BC8
$8BEF
Line 68
35824
35863
$8BF0
$8C17
Line 69
35864
35903
$8C18
$8C3F
Line 70
35904
35943
$8C40
$8C67
Line 71
35944
35983
$8C68
$8C8F
Line 72
35984
36023
$8C90
$8CB7
Line 73
36024
36063
$8CB8
$8CDF
Line 74
36064
36103
$8CE0
$8007
Line 75
36104
36143
$8D08
$8D2F
Line 76
36144
36183
$8D30
$8057
Line 77
36184
36223
$8D58
$8D7F
Line 78
36224
36263
$8D80
$8DA7
Line 79
36264
36303
$8DA8
$8DCF
Line 80
36304
36343
$8DD0
S8DF7
Line 81
36344
36383
$8DF8
S8E1F
Line 82
36384
36423
$8E20
$8E47
Line 83
36424
36463
$8E48
$8E6F
461
Table E-1 6— cont. Absolute Addresses for ATARI
BASIC Mode-8 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 84
Line 85
Line 86
36464
36503
$8E70
$8E97
36504
36543
$8E98
$8EBF
36544
36583
$8EC0
$8EE7
Line 87
36584
36623
$8EE8
$8F0F
Line 88
36624
36663
$8F10
$8F37
Line 89
36664
36703
$8F38
$8F5F
Line 90
36704
36743
$8F60
$8F87
Line 91
36744
36783
S8F88
$8FAF
Line 92
36784
36823
$8FB0
$8FD7
Line 93
36824
36863
$8FD8
$8FFF
Line 94
36864
36903
$9000
$9027
Line 95
36904
36943
$9028
$904F
Line 96
36944
36983
$9050
$9077
Line 97
36984
37023
$9078
$909F
Line 98
37024
37063
$90A0
$90C7
Line 99
37064
37103
$90C8
$90EF
Line 100
37104
37143
$90F0
$9117
Line 101
37144
37183
$9118
$91 3F
Line 1 02
37184
37223
$9140
$9167
Line 103
37224
37263
$9168
$91 8F
Line 104
37264
37303
$9190
$91 B7
Line 105
37304
37343
$91 B8
$91 DF
Line 106
37344
37383
$91 EO
$9207
Line 107
37384
37423
$9208
$922F
Line 108
37424
37463
$9230
$9257
Line 109
37464
37503
$9258
$927F
Line 110
37504
37543
$9280
$92A7
Line 1 1 1
37544
37583
$92A8
$92CF
Line 112
37584
37623
$92D0
$92F7
Line 1 13
37624
37663
$92F8
$931 F
Line 114
37664
37703
$9320
$9347
Line 115
37704
37743
$9348
$936F
Line 116
37744
37783
$9370
S9397
Line 117
37784
37823
S9398
$93BF
Line 118
37824
37863
$93C0
$93E7
Line 119
37864
37903
$93E8
$940F
Line 120
37904
37943
S9410
$9437
Line 121
37944
37983
$9438
$945F
Line 122
37984
38023
$9460
$9487
Line 123
38024
38063
$9488
$94AF
Line 124
38064
38103
$94B0
$9407
Line 125
38104
38143
$94D8
$94FF
462
Table E-1 6— cont. Absolute Addresses for ATARI
BASIC Mode-8 Screen Display
Line
Decimal
Hexadecimal |
Start
End
Start
End
Line 126
38144
38183
$9500
$9527
Line 127
38184
38223
$9528
$954F
Line 128
38224
38263
$9550
$9577
Line 129
38264
38303
$9578
$959F
Line 130
38304
38343
$95A0
$95C7
Line 131
38344
38383
$95C8
$95EF
Line 132
38384
38423
$95F0
$9617
Line 133
38424
38463
$9618
$963F
Line 134
38464
38503
$9640
$9667
Line 135
38504
38543
$9668
$968F
Line 136
38544
38583
$9690
$9667
Line 137
38584
38623
$9688
$96DF
Line 138
38624
38663
$96E0
$9707
Line 139
38664
38703
$9708
$972F
Line 140
38704
38743
$9730
$9757
Line 141
38744
38783
$9758
$977F
Line 142
38784
38823
$9780
$97A7
Line 143
38824
38863
$97A8
$97CF
Line 144
38864
38903
$9700
$97F7
Line 145
38904
38943
$97F8
$981 F
Line 146
38944
38983
$9820
$9847
Line 147
38984
39023
$9848
$986F
Line 148
39024
39063
$9870
$9897
Line 149
39064
39103
$9898
$98BF
Line 150
39104
39143
$98C0
$98E7
Line 151
39144
39183
$98E8
$990F
Line 152
39184
39223
$9910
$9937
Line 153
39224
39263
$9938
$995F
Line 154
39264
39303
$9960
$9987
Line 155
39304
39343
$9988
$99AF
Line 156
39344
39383
$99B0
$9907
Line 157
39384
39423
$9908
$99FF
Line 158
39424
39463
$9A00
$9A27
Line 159
39464
39503
$9A28
$9A4F
Text window
addressing b
egins here
Line
40800
40839
$9F60
$9F87
Line 1
40840
40879
$9F88
$9FAF
Line 2
40880
40919
$9FB0
$9FD7
Line 3
40920
40959
$9FD8
$9FFF
463
Table E-17. Absolute Addresses for ATARI
BASIC Mode-24 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line
33104
33143
$8150
$8177
Line 1
33144
33183
$8178
$819F
Line 2
33184
33223
$81 AO
$81 C7
Line 3
33224
33263
$81 C8
S81EF
Line 4
33264
33303
$81 FO
$8217
Line 5
33304
33343
$8218
S823F
Line 6
33344
33383
$8240
$8267
Line 7
33384
33423
$8268
$828F
Line 8
33424
33463
$8290
$8287
Line 9
33464
33503
$82B8
$82DF
Line 10
33504
33543
$82E0
$8307
Line 1 1
33544
33583
$8308
$832F
Line 12
33584
33623
$8330
$8357
Line 13
33624
33663
$8358
S837F
Line 14
33664
33703
$8380
$83A7
Line 1 5
33704
33743
$83A8
$83CF
Line 16
33744
33783
$8300
$83F7
Line 17
33784
33823
$83F8
$841 F
Line 1 8
33824
33863
$8420
$8447
Line 1 9
33864
33903
$8448
$846F
Line 20
33904
33943
$8470
$8497
Line 21
33944
33983
$8498
$84BF
Line 22
33984
34023
$84C0
$84E7
Line 23
34024
34063
$84E8
$850F
Line 24
34064
34103
$8510
$8537
Line 25
34104
34143
$8538
$855F
Line 26
34144
34183
$8560
$8587
Line 27
34184
34223
$8588
$85AF
Line 28
34224
34263
$8580
$8507
Line 29
34264
34303
$8508
$85FF
Line 30
34304
34343
$8600
$8627
Line 31
34344
34383
$8628
$864F
Line 32
34384
34423
$8650
$8677
Line 33
34424
34463
$8678
S869F
Line 34
34464
34503
$86A0
$86C7
Line 35
34504
34543
$86C8
$86EF
Line 36
34544
34583
$86F0
$8717
Line 37
34584
34623
$8718
$873F
Line 38
34624
34663
$8740
$8767
464
Table E-17— cont. Absolute Addresses for ATARI
BASIC Mode-24 Screen Display
Line
Decimal
Hexadecimal |
Start
End
Start
End
Line 39
34664
34703
$8768
$878F
Line 40
34704
34743
$8790
$87B7
Line 41
34744
34783
$8788
$87DF
Line 42
34784
34823
$87E0
$8807
Line 43
34824
34863
$8808
$882F
Line 44
34864
34903
$8830
$8857
Line 45
34904
34943
$8858
$887F
Line 46
34944
34983
$8880
$88A7
Line 47
34984
35023
$88A8
$88CF
Line 48
35024
35063
$8800
$88F7
Line 49
35064
35103
$88F8
$891 F
Line 50
35104
35143
$8920
$8947
Line 51
35144
35183
$8948
$896F
Line 52
35184
35223
$8970
$8997
Line 53
35224
35263
$8998
$89BF
Line 54
35264
35303
$89C0
$89E7
Line 55
35304
35343
$89E8
S8A0F
Line 56
35344
35383
$8A10
$8A37
Line 57
35384
35423
$8A38
$8A5F
Line 58
35424
35463
$8A60
$8A87
Line 59
35464
35503
$8A88
$8AAF
Line 60
35504
35543
$8AB0
$8AD7
Line 61
35544
35583
$8AD8
$8AFF
Line 62
35584
35623
$8800
$8827
Line 63
35624
35663
$8828
$8B4F
Line 64
35664
35703
$8B50
$8877
Line 65
35704
35743
$8878
$8B9F
Line 66
35744
35783
$8BA0
$8BC7
Line 67
35784
35823
$8BC8
$8BEF
Line 68
35824
35863
$8BF0
$8C17
Line 69
35864
35903
$8C18
$8C3F
Line 70
35904
35943
$8C40
$8C67
Line 71
35944
35983
$8C68
$8C8F
Line 72
35984
36023
$8C90
$8CB7
Line 73
36024
36063
$8CB8
$8CDF
Line 74
36064
36103
$8CE0
$8007
Line 75
36104
36143
$8D08
$8D2F
Line 76
36144
36183
$8030
$8057
Line 77
36184
36223
$8058
$8D7F
465
Table E-1 7— cont. Absolute Addresses for ATARI
BASIC Mode-24 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 78
36224
36263
$8D80
$8DA7
Line 79
36264
36303
$8DA8
$8DCF
Line 80
36304
36343
$8DD0
$8DF7
Line 81
36344
36383
$8DF8
$8E1F
Line 82
36384
36423
$8E20
$8E47
Line 83
36424
36463
$8E48
$8E6F
Line 84
36464
36503
$8E70
$8E97
Line 85
36504
36543
$8E98
$8EBF
Line 86
36544
36583
$8EC0
$8EE7
Line 87
36584
36623
S8EE8
$8F0F
Line 88
36624
36663
$8F10
$8F37
Line 89
36664
36703
$8F38
$8F5F
Line 90
36704
36743
$8F60
$8F87
Line 91
36744
36783
$8F88
$8FAF
Line 92
36784
36823
$8FB0
$8FD7
Line 93
36824
36863
S8FD8
$8FFF
Line 94
36864
36903
$9000
$9027
Line 95
36904
36943
$9028
$904F
Line 96
36944
36983
$9050
$9077
Line 97
36984
37023
$9078
$909F
Line 98
37024
37063
$90A0
$90G7
Line 99
37064
37103
$90C8
$90EF
Line 100
37104
37143
$90F0
$9117
Line 101
37144
37183
$9118
$913F
Line 102
37184
37223
$9140
$9167
Line 103
37224
37263
$9168
$918F
Line 104
37264
37303
$9190
$91 B7
Line 105
37304
37343
$91 B8
$91DF
Line 106
37344
37383
$91 EO
$9207
Line 107
37384
37423
$9208
$922F
Line 108
37424
37463
$9230
$9257
Line 109
37464
37503
$9258
$927F
Line 110
37504
37543
$9280
$92A7
Line 111
37544
37583
$92A8
$92CF
Line 112
37584
37623
$92D0
$92F7
Line 113
37624
37663
$92F8
$931 F
Line 114
37664
37703
$9320
$9347
Line 115
37704
37743
$9348
$936F
466
Table E-17— cont. Absolute Addresses for ATARI
BASIC Mode-24 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 116
37744
37783
$9370
$9397
Line 117
37784
37823
$9398
$93BF
Linens
37824
37863
$93C0
$93E7
Line 119
37864
37903
$93E8
$940F
Line 120
37904
37943
$9410
$9437
Line 121
37944
37983
$9438
$945F
Line 122
37984
38023
$9460
$9487
Line 123
38024
38063
$9488
$94AF
Line 124
38064
38103
$9480
$9407
Line 125
38104
38143
$9408
$94FF
Line 126
38144
38183
$9500
$9527
Line 127
38184
38223
$9528
$954F
Line 128
38224
38263
$9550
$9577
Line 129
38264
38303
$9578
$959F
Line 130
38304
38343
$95A0
$95C7
Line 131
38344
38383
$95C8
$95EF
Line 132
38384
38423
$95F0
$9617
Line 133
38424
38463
$9618
$963F
Line 134
38464
38503
$9640
$9667
Line 135
38504
38543
$9668
$968F
Line 136
38544
38583
$9690
$9687
Line 137
38584
38623
$9688
$96DF
Line 138
38624
38663
$96E0
$9707
Line 139
38664
38703
$9708
$972F
Line 140
38704
38743
$9730
$9757
Line 141
38744
38783
$9758
$977F
Line 142
38784
38823
$9780
$97A7
Line 143
38824
38863
$97A8
$97CF
Line 144
38864
38903
$9700
$97F7
Line 145
38904
38943
$97F8
$981 F
Line 146
38944
38983
$9820
$9847
Line 147
38984
39023
$9848
$986F
Line 148
39024
39063
$9870
$9897
Line 149
39064
39103
$9898
$98BF
Line 150
39104
39143
$98C0
$98E7
Line 151
39144
39183
$98E8
$990F
Line 152
39184
39223
$9910
$9937
Line 153
39224
39263
$9938
$995F
467
Table E-17— cont. Absolute Addresses for ATARI
BASIC Mode-24 Screen Display
Line
Decimal
Hexadecimal
Start
End
Start
End
Line 154
39264
39303
S9960
$9987
Line 1 55
39304
39343
$9988
$99AF
Line 156
39344
39383
$9980
$9907
Line 157
39384
39423
$9908
$99FF
Line 1 58
39424
39463
$9A00
$9A27
Line 159
39464
39503
$9A28
$9A4F
Line 160
39504
39543
$9A50
$9A77
Line 161
39544
39583
$9A78
$9A9F
Line 162
39584
39623
$9AA0
$9AC7
Line 163
39624
39663
$9AC8
$9AEF
Line 1 64
39664
39703
$9AF0
$9B17
Line 165
39704
39743
$9B18
$9B3F
Line 166
39744
39783
$9B40
$9B67
Line 167
39784
39823
$9B68
$9B8F
Line 168
39824
39863
$9890
$9BB7
Line 169
39864
39903
$9BB8
$9BDF
Line 1 70
39904
39943
$9BE0
$9C07
Line 171
39944
39983
$9C08
$9C2F
Line 172
39984
40023
$9C30
$9C57
Line 173
40024
40063
$9C58
$9C7F
Line 1 74
40064
40103
$9C80
$9CA7
Line 1 75
40104
40143
$9CA8
$9CCF
Line 176
40144
40183
$9CD0
$9CF7
Line 177
40184
40223
$9CF8
$901 F
Line 178
40224
40263
$9020
$9047
Line 1 79
40264
40303
$9048
$9D6F
Line 1 80
40304
40343
$9070
$9097
Line 181
40344
40383
$9098
$9DBF
Line 182
40384
40423
$9DC0
$9DE7
Line 183
40424
40463
$9DE8
$9E0F
Line 184
40464
40503
$9E10
$9E37
Line 185
40504
40543
$9E38
$9E5F
Line 186
40544
40583
$9E60
$9E87
Line 187
40584
40623
$9E88
$9EAF
Line 188
40624
40663
$9EB0
$9ED7
Line 189
40664
40703
$9ED8
$9EFF
Line 190
40704
40743
$9F00
$9F27
Line 191
40744
40783
$9F28
$9F4F
468
Appendix F
Derived
Trigonometric Functions
The following functions are not represented in ATARI
BASIC. They can be executed, however, by applying the
corresponding equivalent expressions in Table F-1.
Table F-1 . Derived Trigonometric Functions
Function
Equivalent
Secant
1 /COS(X)
Cosecant
1/SIN(X)
Cotangent
1/TAN(X)
Inverse sine
ATN(X/SQR(1-X*X))
Inverse cosine
Ar-ATN(X/SQR(1-X*X))
Inverse secant
ATN(SQR(X*X-1 ))+SGN(X-1 )**
Inverse cosecant
ATN(1 /SQR(X*X-1 ))+SGN(X-1 )+k
Inverse cotangent
ATN(X)+A
Hyperbolic sine
(EXP(X)-EXP(-X))/2
Hyperbolic cosine
(EXP(X)+EXP(-X))/2
Hyperbolic tangent
(EXP(X)-EXP(-X))/{EXP(X)+EXP(-X))
Hyperbolic secant
2/(EXP(X)+EXP(-X))
Hyperbolic cosecant
2/(EXP(X)-EXP(-X))
Hyperbolic cotangent
(EXP(X)+EXP(-X))/(EXP(X)-EXP(-X))
Inverse hyperbolic sine
L0G(X+SQR(X*X+1))
Inverse hyperbolic cosine
L0G(X+SQR(X*X-1))
Inverse hyperbolic tangent
L0G((1+X)/n-X))/2
Inverse hyperbolic secant
L0G((1-SQR(1-X»X))/X)
Inverse hyperbolic cosecant
L0G((1 +SGN(X)*SQR(1 +X*X))/X)
Inverse hyperbolic cotangent
L0G((X + 1)/(X-1))/2
NOTE: The value assigned to variable * in these functions should be
1.570796 if in the RAD (radian) mode, or 90 if in the DEG (degree)
mode.
469
Appendix G
ATARI Error and Status Codes
The ATARI operating system does not generate error mes-
sages in a plain-text format. Rather, it displays an error
code number. Table G-1 lists the error code numbers and
their general intrepretations.
The current status of a given lOCB operation can be
checked by executing a STATUS #chan,x statement; where
chart is the lOCB channel to be tested, and x is a numeric
variable that takes on the status code. It is also possible to
see the current status for all eight lOCB channels by PEEK-
ING or loading the 6502 from the following RAM loca-
tions:
Status Register
lOCB Channel
Address
Dec
Hex
833
$0343
1
851
$0353
2
867
$0363
3
883
$0373
4
899
$0383
5
915
$0393
6
931
$03A3
7
947
$0383
Table G-2 shows the status codes (both decimal and
hexadecimal) and their meaning.
471
Table G-1. ATARI Error Codes and Their Meaning
Number
10
11
Meaning
Out of memory.
There is insufficient RAM available for the size of the
program or programming task.
Illegal function call.
A numerical value is too large, too small or has a sign
that is inappropriate for the statement that uses it.
Too many variables.
ATARI BASIC allows no more than 1 28 different var-
iable names to be used throughout the execution of a
program.
String too long.
Actual string assignment contains more characters
than DIMensioned its variable name. The ERROR
message does not appear on all ATARI systems; the
string is simply truncated to the DIMensioned length,
and no interruption occurs.
Out of DATA error.
The number of READ operations executed by the pro-
gram exceeds the number of items in the correspond-
ing DATA list.
Number exceeds 32767.
This error indicates that an operation that is expect-
ing a positive integer value is getting either a value
that exceeds 32767 or is a negative value.
Type mismatch in an INPUT statement.
An INPUT statement that assigns values to a numeri-
cal variable cannot accept a string value from the
keyboard.
DIMension error.
This error occurs when attempting to use a non-
DIMensioned string or array variable, to DIMension
the same string or array variable more than one time,
or to DIMension an array beyond the limit of 32767
elements.
Expression too complex.
A string or arithmetic expression is too complex, an
arithmetic expression contains too many levels of
parentheses nesting, or the program contains too
many nested GOSUB statements.
Floating-point value overflow/underflow.
The result of a floating-point arithmetic operation
yielded a value that exceeds the system's notation
format. This error occurs, for instance, when attempt-
ing to divide by zero.
472
Table G-1 — cont. ATARI Error Codes and Their Meaning
Number
Meaning
12
13
14
15
16
17
18
19
20
21
128
129
Invalid line number.
A GOSUB or GOTO statement references a line
number that does not exist in the program.
NEXT without FOR.
The program contains a NEXT statement that does
not have a corresponding FOR statement.
Line too long.
A BASIC line contains statements that are too com-
plex or too long.
Missing GOSUB or FOR.
The program contains RETURN or NEXT statements
whose corresF>onding GOSUB or FOR was deleted
since the execution of the last RUN command.
RETURN without GOSUB.
The program uses a RETURN statement that does not
have a corresponding GOSUB.
Meaningless RAM-byte error.
Data previously POKEd into RAM does not make
sense when read during the execution of a program.
Possibly a hardware fault, but most often the result of
POKEing invalid data into RAM.
Invalid string character.
A nonnumeric character resides within a string when
the program attempts to execute a VAL function on
that string.
LOAD program too large for RAM.
A program being loaded from cassette or disk is too
long for the amount of RAM that is available in the
system.
Bad device number.
A specified device number is equal to or greater
than 7.
File not in LOAD format.
The program is using a LOAD statement for files or
programs saved with a format other than SAVE.
BREAK abort.
The user aborted an I/O operation by striking the
BREAK key.
Device already OPEN.
The program attempts to OPEN a device channel that
is already OPEN.
473
Table G-1 -cont. ATARI Error Codes and Their Meaning
Number
130
131
132
133
134
135
136
137
138
139
140
141
142
Meaning
Bad device specification.
The program specifies an unrecognized device code,
or the specified device is not properly connected to
the system.
Write-only error.
The program specifies a read operation from a write-
only device (such as a printer).
Bad XIO syntax.
An XIO statement is using inappropriate or unintellig-
ible specifications.
Not-OPEN error.
Program attempts to use a device or file that was not
previously OPENed.
Bad I/O channel number.
Program attempts to use a device number other than
1,2, 3, 4, 5, 6, or 7.
Read-only error.
The program attempts to write to a device or file that
is specified for reading operations.
EOF error.
The program has found the End Of a File before
expected.
Truncated record.
Data record Is more than 256 bytes long, and has
been truncated at that point.
Device timeout.
A specified I/O device does not respond after a
period of repeated trying.
Device NAK
A specified serial port or disk does Not AcKnowledge
attempts to use it.
Bus framing error.
Serial-bus data is improperly formatted or inconsist-
ent.
Illegal cursor position.
A cursor function is generating an illegal line/row
position for the current screen mode.
Serial frame overrun.
Inconsistent serial-bus data.
474
Table G-1 — cont. ATARI Error Codes and Their Meaning
Number
Meaning
143
144
145
146
147
160
161
162
163
164
165
166
167
168
Serial frame checksum error.
Inconsistent serial-bus data.
Disk error.
Disk system is not responding properly; the disk
might be write-protected, its directory garbled or the
drive is malfunctioning.
Read-after-Write error.
Disk or screen handler finds a discrepancy between
what was written to RAM and what actually appears
there.
Operation not implemented.
A specified operation cannot be carried out.
Out of graphics RAM.
Insufficient amount of RAM for the graphics mode
being implemented.
Invalid drive number.
Program attempts to use an invalid disk drive des-
ignation.
Too many files.
The program attempts to open more than three files
at a time.
Disk full.
All disk sectors are in use.
Device I/O error.
The I/O system has encountered an error that it can-
not handle.
File number mismatch.
A discrepancy exists in the disk file management
system.
Bad file name.
Program cites an invalid file name.
POINT length error.
A POINT statement refers to a sector byte that does
not exist.
File locked.
The program attempts to modify or erase a locked
disk file.
Invalid XIO command.
An XIO command is invalid, inappropriate or contains
a syntax error.
475
Table G-1 — cont. ATARI Error Codes and Their Meaning
Number
169
170
171
Meaning
Directory full.
A given directory cannot contain more than 64 file
names.
File not found.
The program specifies a file name that is not included
in the current disk directory.
Invalid POINT.
A POINT statement refers to a disk sector that is not
included in the current file.
476
Table G-2. ATARI lOCB (I/O Control Block)
Status Codes and Their Meaning
HEX
DEC
Meaning
$01
001
Operation complete (no errors)
$03
003
End of file (EOF)
$80
128
BREAK key abort
$81
129
lOCB already in use (OPEN)
$82
130
Nonexistent device
$83
131
Opened for write only
$84
132
Invalid command
$85
133
Device or file not open
$86
134
Invalid lOCB number (Y register only)
$87
135
Opened for read only
$88
136
End of file (EOF) encountered
$89
137
Truncated record
$8A
138
Device timeout (doesn't respond)
$8B
139
Device NAK
$8C
140
Serial bus input framing error
$8D
141
Cursor out of range
$8E
142
Serial bus data frame overrun error
$8F
143
Serial bus data frame chiecksum error
$90
144
Device-done error
$91
145
Bad screen mode
$92
146
Function not supported by handler
$93
147
Insufficient memory for screen mode
$A0
160
Disk drive number error
$A1
161
Too many open disk files
$A2
162
Disk full
$A3
163
Fatal disk I/O error
$A4
164
Internal file number mismatch
$A5
165
Filename error
$A6
166
Point data length error
$A7
167
File locked
$A8
168
Command invalid for disk
$A9
169
Directory full (64 files)
$AA
170
File not found
SAB
171
Point invalid
477
Appendix H
ATARI 400/800
Hardware Details
Fig. H-1. 6502 microprocessor
pinout diagram.
Vss(^
^ (giRES
RDY(~) (s)<<.2(0UT)
.(OUTjT
^ te)s.o.
IRQO
J) {|)<()o(IN)
N.CO
!) (s)N.C.
NMIO
5) (s)N.C.
SYNCO
?) {s)r«;
Vcc^
^ ©DBO
ABOO
») (s)DB1
AB1(
s) fe)DB2
AB2(
^ (g)DB3
AB3(
s) (H)DB4
AB4f
a) (a) DBS
AB5(
5) (5)dB6
AB6(
s) (s)DB7
AB7(
a) (5)AB15
AB8(
=) (X)AB14
AB9(
s) (S)aB13
AB10(
s) (g)AB12
AB11{
§) @Vss
479
1 1 1 1 1 1 1
(D (D tD to
Fig. H-2. 6502 microprocessor
480
sz sz.
HQV nvNaaiNi
3£:
11111111
sna ss3uaav
internal block diagram.
481
A
DC
O
-&
I
5
Q.
:?
/
/
a.
-©
I
S
\
-©-
I
- 5
a.
V
9
5 m
LU
IT
>
>
y
II oc
I <
5!^
-©■-I
-&
3
O
3
o
Fig. H-3. 6502 microprocessor clock timing diagram.
482
Tows = READ/WRITE SETUP TIME
Tads = ADDRESS SETUP TIME
TaCC = MEMORY READ ACCESS TIME
Tdsu = O^TA STABILITY TIME PERIOD
Thr = DATA HOLD TIME-READ
Thw = DATA HOLD TIME-WRITE
Tuns = DATA SETUP TIME
Trdy = RDY, S.O. SETUP TIME
TsYNC = SYNC SETUP TIME
Tha = ADDRESS HOLD TIME
ThrW =R™ HOLD TIME
Fig. H-4- 6502 microprocessor READ-^cycle timing diagram.
483
DATA -
FROM
MPU
LEGEND
Trws = READ/WRITE SETUP TIME
Tads = ADDRESS SETUP TIME
Thvv = data hold TIME
Tmds = DATA SETUP TIME
-REF'B"
2.0 V-
0.8 V-
Fig. H-5. 6502 microprocessor WRITE-cycle timing diagram.
484
Fig. H-6. ATARI Home Com-
puter GTIA (or CTIA)
pinout.
AlG
^ ®A2
AOM ©A3
Vssft (£)A^
D3« ©D"
02© (w)D5
DKj
») (s)D6
DOO
?) (5)D7
TOO
?) (5)R/W
Tif
5) te)csi
T2(
3) (5)LUM3
T3(]
5) (S)4>2
S0(
s) (3)F<t)0
S1(
2) (s)OSC
S2(
g ®Vcc
S3(
5) (5) HALT
(HC)(
5) (5) C SYNC
DELI
g) (5) LUM 2
ANOi
5) (5)LUM1
AN1
(3) (5)lumo
AN2
(a) (a) COL
485
VSS(
5
|)D4
ANO{~) I
S)D5
AN1(^ (|
g)D6
LPI
i
b)D7
AN2(
5) RESET
RNM1(
% I
5)F<()0
NM1(
5 \
s)*0
REF(
% }
b)D3
HALT(
% I
a)D2
A3(
s)
2)D1
A2(
S) V
^DO
A1^
% S
J)<fr2
Mi
^ Q
S)A4
FWWt
5) Q
5)A5
RDYf
^ Q
S)A6
A10(
s) n
j)A7
A12t
5 y
s)A8
A13f
s) (E
3)A9
A14f
^ ^
3)A11
A15f
g) (|
yvcc
Fig. H-7. ATARI ANTIC pinout.
SERIAL I/O JACK
2 4
® @
8 10 12
® ®
® ® ® ® ® ® ®
1 3 5 7 9 11 13
1. CLOCK INPUT
2. CLOCK OUTPUT
3. DATA INPUT
4. GROUND
5. DATA OUTPUT
6. GROUND
7. COMMAND
8. MOTOR CONTROL
9. PROCEED
10. +5/READY
11. AUDIO INPUT
12. +12 VOLTS
13. INTERRUPT
Fig. H-8. ATARI serial I/O jack pinout.
486
CONTROLLER JACK
1. (JOYSTICK) FORWARD INPUT
2. (JOYSTICK) BACK INPUT
3. (JOYSTICK) LEFT INPUT
4. (JOYSTICK) RIGHT INPUT
5. B POTENTIOMETER INPUT
6. TRIGGER INPUT
7. +5 VOLTS
8. GROUND
9. A POTENTIOMETER INPUT
Fig. H-9. ATARI controller jack pinout.
MONITOR JACK (800 ONLY)
DJ.N 5 JACK
AUDIO OUTPUT
COMPOSITE CHROMA
COMPOSITE LUMINANCE
COMPOSITE VIDEO
GROUND
Fig. H-10. ATARI 800 monitor jack pinout.
487
Index
Accessing character set, 154-155
Addr, 152
Addresses
mode-0 screen, 436
mode-l screen, 437
mode-2 screen, 439
mode-3 screen, 440
mode-4 screen, 442
mode-5 screen, 446
mode-6 screen, 217, 450
mode-7 screen, 455
mode-8 screen, 232, 460
mode-17 screen, 438
mode-18 screen, 439
mode-19 screen, 203, 441
mode-20 screen, 218, 444
mode- 21 screen, 204, 448
mode-22 screen, 219, 452
nnode-23 screen, 205, 457
mode-24 screen, 236, 464
starting and ending, 174
Animation, 244
Antenna switch, 16
ANTIC, 255
device, 345
instruction set, 300-303
map detail, 345
screen modes, 301
Append, 31
Arithmetic operators, 55
Arrays, DIM, 48-54
ASCII, 60
codes, 61
Asterisk option, 31
ATARI
ATASCII character set, 402
BASIC, 40
commands, 73-113
reserved words, 396
error codes, 472
internal character set, 135, 417
status codes, 477
system configuration, 15-18
ATASCII, 60
character set, 402
coded BASIC programs, 264-266
character set, 120
B
BASIC
commands, 68
ROM area: 40960-49151, 338
system RAM, 337
tokenized, 307-310
variables, 44-48
Baud rate, 285-286
Binary-to
-decimal conversion, 387-388
-hexadecimal conversion, 388-390
Bit
map, player/missile, 245-246
protecting player/missile,
249-250
maps for missile figures, 243-244
for player figures, 241-243
Boundary values for RAM addresses,
248
BREAK, 22
Buffer, INPUT string, 43
489
Byte
least significant, 386
most significant, 386
Cable assembly, 17
CAPS/LOWR, 20
Channel switch, 16
Character
set, accessing, 154-155
ATARI ATASCII, 402
internal, 417
CLOAD, 24
CLOSE, 25
Closing lOCB channels, 278-283
CLR/SET/TAB, 22
Codes, color register, 161
COLCRS, 157
Collision detection, 257-261
COLOR, 148
registers, 183-184
codes, 161
screen mode 4, 204
mode 6, 204
sequences, 170
Column/row
format, 145-147
screen formats, 184-188, 203
techniques, 148-149
Command(s), 68-73, 308
Common multiple-peripheral
system, 18
Configurations, player and missile,
240-250
Constants
numeric, 39-44
string, 39-44
Control
keys, 20-22
statements, 68
Conversion
binary to decimal, 387-388
to hexadecimal, 388-390
decimal to binary, 390
to hexadecimal, 384-385
hexadecimal to binary, 390
to decimal, 382-383
table, decimal, 391
Copying
DOS files, 32-33
files to same disk, 28-30
CSAVE, 24
CTIA device, 341
CTRL, 21
key operations, 428
Cursor
position, 23
registers, 143
related BASIC statements, 143
Custom
character
set for mode 0, 179-182
for mode 1,179-182
for mode 2, 179-182
DATA pointer, 50
Decimal
conversion table, 391
to binary conversion, 390
hexadecimal conversions,
384-385
2-byte decimal format, 385-386
DELETE/BACK S, 21
Deleting files, 30-31
DIMensioning
numeric arrays, 48-54
string variables, 48-54
Directory, 26-28
Disk
directory, 26-28
drive I/O, 270-275
loading programs, 36-37
one, 17-18
saving programs, 36-37
duplicating, 33-35
formatting, 33
operations, routine, 26-37
utility operations, 26
Display
list, 303-306
locating, 306-307
DMACTL, 251
DOS
files, copying, 32-33
menu, 26
system, 18
RAM usage, 338
DRAWTO, 148
Duplicating entire disk, 33-35
490
Editing features, screen, 22-23
ENTER "C:", 264-266
"D:", 270-272
ESC, 22
Execute DOS, 26
Existing files, renaming, 31
Fast forward, 24
Flle(s)
copying DOS, 32-33
operation, 35-36
deleting, 30-31
designated, 37
locking, 32
name extension, 37
nonprogram, 266-269
renaming existing, 31
unlocking, 32
Floating-point notation, 40
Formatting a disk, 33
Four-color modes 3, 5, 7, 182-195
Full-screen formats, 168-178
Function(s)
summary, 68-73
tokens, 310
Game-controller commands, 73
GET, 149-150, 268-269, 274-275
in mode 1, 165-166
in mode 2, 165-166
Global file names, 30
GPRIOR, 255
GRACTL, 251
Graphics
commands, 73
mode-0, 143
mode-1, 152-178
mode-2, 152-178
operations, 184-188
split screen, 144
GTIA device, 341
H
Hexadecimal
to binary conversion, 390
decimal conversions, 382-383
HITCLR, 257
Horizontal 6-position registers 254
Hue, 115
values, 118
I
INPUT, 266-268, 272-274
String buffer, 43
Input/output commands, 68
INSERT, 21
interface module, 18
Interference, 16
Internal character set, 417
Invalid numeric variable names, 47
Inverse-key operations, 429
I/O ROM area: 53248-55295, 340
Jack, peripheral, 77
Key codes, 426
Keyboard operations, special
19-22
Keystrokes, 426
Keys, control, 20-22
Least
significant byte, 386
nibble, 382
LIST "C:", 264-266
"D:", 270-272
Loading
binary programs, 277
programs, 24-25
with disk drive, 36-37
under DOS, 275-277
LOCATE, 149-150
in mode 1, 165-166
in mode 2, 165-166
Locking files, 32
Logical operators, 62-63
LPRINT,25
LSB, 386
Luminance, 115
values, 118
M
Machine
language options, 36
routine, 300
491
Machine — cont.
routine, 296-299
Map development, 242
Margins, mode-0, 147
Math functions, 68
Memory, 22
MEM.SAV, 35
Minimum working system, 15-16
Missile figures, bit maps, 243-244
Mode-0
color registers, 144-145
column/row format, 145-147
graphics, 143
margins, 147
PRINT, 147
screen, 143
text screen, 144
Mode-1
color registers, 153-154
graphics, 152-178
Mode-2
color registers, 153-154
graphics, 152-178
Mode-8 screen, 216-238
Modes, screen, 115-143
Most
significant byte, 386
nibble, 382
MSB, 386
Multiple-peripheral system, 18
Musical scores, reproducing, 292
N
Names
invalid numeric variable, 47
valid numeric variable, 46
variable, 44-48
NEWROW, 160
Nibble, 381
least significant, 382
most significant, 382
Nonprogram files, 266-269
Notation
floating point, 40
scientific, 40
Null string, 44
Numeric
arrays, DIM, 48-54
constants, 39-44
variable(s), 44, 45-47
names, valid, 46
Numerical variable names, invalid,
47
Numvar, 150
OLDCOL, 160
OLDROW, 160
One disk drive, 17-18
OPEN, 266
Opening lOCB channels, 278-283
Operating system ROM area:
552%-65535, 346-348
Operator(s), 55-66
arithmetic, 55
logical, 62-63
order of precedence, 64-66
relational, 56-62
tokens, 309
Parity, 286-288
PEEK, 150
Peripheral jack, 17
PIA
device, 345
map detail, 345
Pixel, 193
Play, 24
Player
and missile configurations,
240-250
figures, bit maps, 241-243
Player/missile
bit map, 245-246
protecting, 249-250
setting starting address,
247-249
color registers, 251
colors, setting, 251
figures, adjusting width, 250
moving, 254-255
width registers, 250
graphics, initiating, 251-253
terminating, 251-253
Player/playfield priorities,
255-256
PLOT, 148
POKE, 144
operations for GRACTL register,
252
492
POKEY
device, 343
map detail, 343
POSITION, 148
statement, 159
Power switch, 16
Powers of 2, 389
PRINT, 41, 266-268, 272-274
Print-cursor features, 145
Program
editing features, 22
memory, 22
recorder, 16-17, 23-25
connecting to system, 24
I/O, 263-269
Programs, loading, 24-25
saving, 24-25
Protecting player/missile bit map,
249-250
PUT, 149-150, 268-269, 274-275
in mode 1, 165-166
in mode 2, 165-166
RAM, 23, 150-152
address, 312
READY, 16
Record, 24
Recorder
connecting to system, 24
I/O, working with program,
263-269
program, 16-17, 23-25
Registers
color, 183-184
mode-0 color, 144-145
mode-1, 153-154
mode-2, 153-154
Relational operators, 56-62
Renaming existing files, 31
Reserved
word list, 46
words, ATARI BASIC, 396
RETURN, 20
Return to BASIC, 28
Reverse, 24
ROWCRS, 157
Running
binary files under DOS, 275-277
programs, 277
Saving
binary data, 276-277
programs, 276-277
programs, 24-25
with disk drives, 36-37
under DOS, 275-277
Scientific notation, 40
Screen
display lists, 300-307
editing features, 22-23
mode 8, 216-238
modes, features, 115-143
RAM address formats, 188-195
format for mode 4, 209-216
for mode 6, 209-216
SETCOLOR, 144
Setting starting address of
player/missile bit map,
247-249
SHIFT, 20
Single-key operations, 426
6502 instruction set, 349
Sound
commands, 73
effects, experimenting, 292-293
features, 289-293
statement, 290-292
Split-screen graphics, 144
Stack RAM, 313
Starting and ending addresses, 174
for mode-4 screen, 216
for mode-6 screen, 217
for mode-7 screen RAM, 198
for mode-8 screen, 232
for mode-19 screen, 203
for mode-20 screen, 218
for mode-21 screen, 204
for mode-22 screen, 219
for mode-23 screen, 205
for mode-24 screen, 236
Start-up
procedure, 17
sequence, 18
Statements, summary, 68-73
Stop bits, 285-286
String
buffer, INPUT, 43
commands, 68
constants, 39-44
493
String— com.
null, 44
variables, 44, 47-48
DIM, 48-54
Subscripted
arrays, 51-54
numeric variables, 51-54
Switch
antenna, 16
channel, 16
power, 16
SYSTEM RESET, 28
Tape counter, 23
Text window, 144
Tokenized BASIC, 307-310
Translation modes, 286-288
Turn-on procedure, 18
Two
byte decimal to conventional
decimal format, 387
color mode 4, 195-216
mode 6, 195-216
TXTCOL,157
TXTROW, 157
Unlocking files, 32
USR function, 293-299
V
Valid numeric variable names, 46
Variable(s)
BASIC, 44-48
DIM, 48-54
names, 44-48
invalid numeric, 47
valid numeric, 46
numeric, 44, 45-47
string, 44, 47-48
W
Wild-card file names, 30
Words
ATARI BASIC reserved, 396
list, reserved, 46
size, 285-286
Working system, minimum, 15-16
X
XIO command, 283-288
Z
Zero page, 313
494
Computer Direct
312/382-5050
Programmer^
Reference Guide for
the ATARI 400 /800~
Computers
-i
Programmer's Reference Guide for the ATARI 400/800 Computers
• Introduces some of the fundamental concepts of BASIC language
• Provides a ready reference for the ATARI BASIC commands
• Discusses the 8 different screen modes and their 21 variations
• Features the enhanced animation package (player/missile/graphics)
• Covers the flexible I/O system
• Describes the memory mop
• Contains the 6502 instruction set
• Covers the numbering system
— Hexadecimal-to-decimal conversion
— Decimal-to-hexadecimal conversion
—Binary-to-decimal conversion — !
• Lists ATARI BASIC reserved words and tokens
• Gives ATARI character codes
• Features the ATARI keyboard codes ~-
• Lists the error code numbers and their general interpretations
The information contained in this book is organized so the user can
efficiently locate facts and application notes I I
Computer Direct
We Love Our Customers
Box 1001, Barrington, I L 60010
^